2018-04-09 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / pr25682.c
blobecf5669403da2c9177653c02868b2c00cb636617
1 /* PR c/25682 */
2 /* { dg-do compile } */
3 /* { dg-options "-ansi" } */
4 /* { dg-require-effective-target alloca } */
5 /* Test whether we don't ICE on questionable constructs where offsetof
6 should have been used instead. */
8 struct S
10 char a[4];
11 int b;
14 char c[(char *) &((struct S *) 0)->b - (char *) 0]; /* { dg-warning "variably modified" } */
15 char d[(__UINTPTR_TYPE__) &((struct S *) 8)->b]; /* { dg-warning "variably modified" } */
16 char e[sizeof (c) == __builtin_offsetof (struct S, b) ? 1 : -1];
17 char f[sizeof (d) == __builtin_offsetof (struct S, b) + 8 ? 1 : -1];
19 extern void bar (char *, char *);
21 void
22 foo (void)
24 char g[(char *) &((struct S *) 0)->b - (char *) 0];
25 char h[(__UINTPTR_TYPE__) &((struct S *) 8)->b];
26 char i[sizeof (g) == __builtin_offsetof (struct S, b) ? 1 : -1];
27 char j[sizeof (h) == __builtin_offsetof (struct S, b) + 8 ? 1 : -1];
28 bar (g, h);