Debian Codegraph @

gcc/testsuite/g++.dg/ext/flexary3.C

raw
1 // PR c++/54441 - [4.7/4.8 Regression] Infinite loop with brace initializer
2 // on zero-length array
3 // Note that although the definition of struct s in the test case for
4 // c++/54441 was accepted as valid, it is, in fact, invalid in C, and
5 // as noted in c++/42121, should be treated as invalid in C++ as well.
6 // The test verifies that gcc detects, reports, and handles both errors
7 // gracefully.
8 // Note also that the error(s) issued for the invalid initializer depend
9 // on c++/55606.
10
11 // { dg-options "" }
12
13 struct s {
14 char c[];
15 };
16
17 int main()
18 {
19 struct s s = { .c = 0 };
20 // { dg-error "non-static initialization of a flexible array member" "" { target *-*-* } .-1 }
21 return 0;
22 }