1/* PR middle-end/13400 */
2/* The following test used to fail at run-time with a write to read-only
3   memory, caused by if-conversion converting a conditional write into an
4   unconditional write.  */
5
6typedef struct {int c, l; char ch[3];} pstr;
7const pstr ao = {2, 2, "OK"};
8const pstr * const a = &ao;
9
10void test1(void)
11{
12    if (a->ch[a->l]) {
13        ((char *)a->ch)[a->l] = 0;
14    }
15}
16
17void test2(void)
18{
19    if (a->ch[a->l]) {
20        ((char *)a->ch)[a->l] = -1;
21    }
22}
23
24void test3(void)
25{
26    if (a->ch[a->l]) {
27        ((char *)a->ch)[a->l] = 1;
28    }
29}
30
31int main(void)
32{
33    test1();
34    test2();
35    test3();
36    return 0;
37}
38
39