This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/25334] New: The example for flexible array member doesn't work.
- From: "gcc-bugzilla at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Dec 2005 01:37:19 -0000
- Subject: [Bug c/25334] New: The example for flexible array member doesn't work.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Using an example from the GCC documentation doesn't work. I don't know if the
documentation is broken
or the compiler.
Environment:
System: FreeBSD inchoate.localdomain 7.0-CURRENT FreeBSD 7.0-CURRENT #0: Sat
Oct 8 10:25:52 CST 2005 root@:/usr/obj/usr/src/sys/INCHOATE i386
host: i386-portbld-freebsd7.0
build: i386-portbld-freebsd7.0
target: i386-portbld-freebsd7.0
configured with: ./..//gcc-4.1-20051202/configure --disable-nls
--with-system-zlib --with-libiconv-prefix=/usr/local --program-suffix=41
--libdir=/usr/local/lib/gcc/i386-portbld-freebsd7.0/4.1.0
--with-gxx-include-dir=/usr/local/lib/gcc/i386-portbld-freebsd7.0/4.1.0/include/c++/
--disable-shared --disable-libgcj --prefix=/usr/local i386-portbld-freebsd7.0
How-To-Repeat:
This file is based on the example in section 5.12 of the manual (Arrays of Zero
length)
cat >test.c
#include <stdio.h>
int
main(int argc, char **argv) {
struct foo { int x; int y[]; };
struct foo a = { 1, { 2, 3, 4 } };
printf("sizeof(a) = %d\n", sizeof(a));
}
[EOT]
~> gcc41 test.c -o test
[inchoate 11:55] ~ >gcc41 test.c -o test
test.c: In function 'main':
test.c:7: error: non-static initialization of a flexible array member
test.c:7: error: (near initialization for 'a')
gcc 3.4.4 gives the same result.
------- Comment #1 from darius at dons dot net dot au 2005-12-10 01:37 -------
Fix:
Depends whether the compiler or the documentation is wrong :)
--
Summary: The example for flexible array member doesn't work.
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: darius at dons dot net dot au
GCC build triplet: i386-portbld-freebsd7.0
GCC host triplet: i386-portbld-freebsd7.0
GCC target triplet: i386-portbld-freebsd7.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25334