This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]