summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/builtin-object-size-12.c
blob: b21eb0071b340325360e0f4922d41276cf3b7642 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* { dg-do run } */
/* { dg-options "-O2" } */

extern void abort (void);
struct S {
    int len;
    char s[0];
};
int main()
{
  char buf[sizeof (struct S) + 32];
  if (__builtin_object_size (((struct S *)&buf[0])->s, 1) != 32)
    abort ();
  if (__builtin_object_size (((struct S *)&buf[1])->s, 1) != 31)
    abort ();
  if (__builtin_object_size (((struct S *)&buf[64])->s, 0) != 0)
    abort ();
  return 0;
}