2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / 20031215-1.c
blobd62177b261877e093ce488ba3f2b36d831cfe21a
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. */
6 typedef struct {int c, l; char ch[3];} pstr;
7 const pstr ao = {2, 2, "OK"};
8 const pstr * const a = &ao;
10 void test1(void)
12 if (a->ch[a->l]) {
13 ((char *)a->ch)[a->l] = 0;
17 void test2(void)
19 if (a->ch[a->l]) {
20 ((char *)a->ch)[a->l] = -1;
24 void test3(void)
26 if (a->ch[a->l]) {
27 ((char *)a->ch)[a->l] = 1;
31 int main(void)
33 test1();
34 test2();
35 test3();
36 return 0;