This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
PR24138 and flexible arrays in C++
- From: Aldy Hernandez <aldyh at redhat dot com>
- To: gcc at gcc dot gnu dot org, mark at codesourcery dot com
- Cc: jconner at apple dot com
- Date: Thu, 10 Nov 2005 08:41:56 -0400
- Subject: PR24138 and flexible arrays in C++
Hi folks.
The code below is ICE-ing in C++:
typedef struct {
unsigned char dir;
int data[];
} AiDefaultRailBlock;
static const AiDefaultRailBlock _raildata_ai_0 = { 1, { 0, 4 } };
According to our docs, this is valid under flexible arrays:
http://gcc.gnu.org/onlinedocs/gcc-4.0.2/gcc/Zero-Length.html#Zero-Length
Mark has a note on the PR that says C++ does not support flexible arrays,
but our documentation seems to imply we do. The discussion of
zero-length arrays (and flexible arrays) is under the "Extensions to the
C Language Family" section.
Should we specify that flexible arrays are not supported in C++?
How about:
struct foo {
int bar;
int a[];
} hot;
This compiles fine with either C or C++. Shouldn't we disallow this
initialization in C++ if we don't support flexible sized arrays?
Aldy