This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/69696] incorrect initialization of block-scope flexible array members
- From: "egallager at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 29 Aug 2017 01:32:50 +0000
- Subject: [Bug c++/69696] incorrect initialization of block-scope flexible array members
- Auto-submitted: auto-generated
- References: <bug-69696-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69696
Eric Gallager <egallager at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed|2016-02-05 00:00:00 |2017-08-29
CC| |egallager at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #2 from Eric Gallager <egallager at gcc dot gnu.org> ---
I get slightly different output, but same basic problem:
$ /usr/local/bin/g++ -Wall -Wextra -Wpedantic -xc++ -o 69696.exe 69696.c
69696.c:3:22: warning: ISO C++ forbids flexible array member ‘a’ [-Wpedantic]
struct A { int n, a []; };
^
69696.c:4:32: warning: initialization of a flexible array member [-Wpedantic]
struct A a0 = { 1, { 2, 3, 4 } };
^
69696.c: In function ‘int main()’:
69696.c:22:46: warning: initialization of a flexible array member [-Wpedantic]
static struct A a = { 1, { 2, 3, 4 } };
^
69696.c:28:22: warning: function-scope ‘i’ implicitly auto and declared
‘__thread’
__thread int i = X;
^
69696.c:29:27: warning: function-scope ‘a’ implicitly auto and declared
‘__thread’
__thread struct A a = { 1, { 2, 3, 4 } };
^
69696.c:29:48: warning: initialization of a flexible array member [-Wpedantic]
__thread struct A a = { 1, { 2, 3, 4 } };
^
69696.c:30:22: warning: function-scope ‘j’ implicitly auto and declared
‘__thread’
__thread int j = Y;
^
69696.c:36:39: warning: initialization of a flexible array member [-Wpedantic]
struct A a = { 1, { 2, 3, 4 } };
^
$ ./69696.exe
i = 12345678
a = { 1, { 2, 3, 4 }
j = 87654321
i = 12345678
a = { 1, { 0, 0, 4194928 }
j = 87654321
Abort trap
$
Also, as a separate issue, the "implicitly auto and declared __thread" warning
should have its own separate flag controlling it.