1 /* When -fstrict-flex-arrays=1, [], [0], and [1] are treated as flexible
3 /* PR tree-optimization/101836 */
5 /* { dg-options "-O2 -fstrict-flex-arrays=1" } */
9 #define expect(p, _v) do { \
12 printf("ok: %s == %zd\n", #p, p); \
15 printf("WAT: %s == %zd (expected %zd)\n", #p, p, v); \
20 struct trailing_array_1
{
26 struct trailing_array_2
{
32 struct trailing_array_3
{
37 struct trailing_array_4
{
43 void __attribute__((__noinline__
)) stuff(
44 struct trailing_array_1
*normal
,
45 struct trailing_array_2
*trailing_1
,
46 struct trailing_array_3
*trailing_0
,
47 struct trailing_array_4
*trailing_flex
)
49 expect(__builtin_object_size(normal
->c
, 1), 4 * __SIZEOF_INT__
);
50 expect(__builtin_object_size(trailing_1
->c
, 1), -1);
51 expect(__builtin_object_size(trailing_0
->c
, 1), -1);
52 expect(__builtin_object_size(trailing_flex
->c
, 1), -1);
55 int main(int argc
, char *argv
[])
57 stuff((void *)argv
[0], (void *)argv
[0], (void *)argv
[0], (void *)argv
[0]);