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]

Re: PR24138 and flexible arrays in C++


Aldy Hernandez wrote:
> 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. 

What I actually said is that I'm not sure we ought to support this in
C++.  I agree that there's nothing in the manual at the moment that
suggests that we don't support it.  I don't really think anybody has
thought hard about this issue or consciously triedto implement it in G++.

Ideally, I think we would support it; I'm just not sure exactly what
restrictions, if any, should apply to the flexible array data member.
For example, perhaps the type of the elements should be one that does
not require construction.  Perhaps that's OK; I'm just not sure.

-- 
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304


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