summaryrefslogtreecommitdiffstats
path: root/gcc/testsuite/gcc.dg/c99-flex-array-4.c
blob: ab20cf07cc468dd72ab9a22067938456a59cdaba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* Test for flexible array members.  Test for agreement of offset and
   structure size.  This is expected to fail, because of a possible
   defect in the standard.  */
/* Origin: http://gcc.gnu.org/ml/gcc/2002-05/msg02844.html
   from Tony Finch <dot@dotat.at>, adapted to a testcase by Joseph Myers
   <jsm28@cam.ac.uk>.  See also WG14 reflector messages 9571-3.  */
/* { dg-do compile } */
/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */

#include <stddef.h>

struct foo {
  int a;
  short b;
  char pad[];
};

struct bar {
  int a;
  short b;
  char pad[1024];
};

char x[(sizeof(struct foo) == offsetof(struct foo, pad)) ? 1 : -1]; /* { dg-bogus "negative" "sizeof != offsetof" { xfail *-*-* } } */
char y[(offsetof(struct foo, pad) == offsetof(struct bar, pad)) ? 1 : -1];
OpenPOWER on IntegriCloud