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 6 typedef struct {int c, l; char ch[3];} pstr; 7 const pstr ao = {2, 2, "OK"}; 8 const pstr * const a = &ao; 9 test1(void)10void test1(void) 11 { 12 if (a->ch[a->l]) { 13 ((char *)a->ch)[a->l] = 0; 14 } 15 } 16 test2(void)17void test2(void) 18 { 19 if (a->ch[a->l]) { 20 ((char *)a->ch)[a->l] = -1; 21 } 22 } 23 test3(void)24void test3(void) 25 { 26 if (a->ch[a->l]) { 27 ((char *)a->ch)[a->l] = 1; 28 } 29 } 30 main(void)31int main(void) 32 { 33 test1(); 34 test2(); 35 test3(); 36 return 0; 37 } 38 39