2014-04-15 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / builtin-object-size-12.c
blobb21eb0071b340325360e0f4922d41276cf3b7642
1 /* { dg-do run } */
2 /* { dg-options "-O2" } */
4 extern void abort (void);
5 struct S {
6 int len;
7 char s[0];
8 };
9 int main()
11 char buf[sizeof (struct S) + 32];
12 if (__builtin_object_size (((struct S *)&buf[0])->s, 1) != 32)
13 abort ();
14 if (__builtin_object_size (((struct S *)&buf[1])->s, 1) != 31)
15 abort ();
16 if (__builtin_object_size (((struct S *)&buf[64])->s, 0) != 0)
17 abort ();
18 return 0;