On Jul 6, 2010, at 4:53 PM, John Thompson wrote:

> Regarding bug 7032, an error is generated in the following case because of 
> the absence of an array size:
>  
> class test {
> int m;
> unsigned int mDummy[];
> };
> >clang -cc1 AttributeAligned1.cpp
> AttributeAligned1.cpp:3:14: error: field has incomplete type 'unsigned int []'
> unsigned int mDummy[];
>              ^
> 1 error generated.
> According to the standards C99_n1124 at 6.2.5.p22 and C++_n2723 at 3.9.1.p5 
> this is a legitimate error.  However, gcc doesn't flag it.  What do we do in 
> this kind of case, regarding maintaining compatibility and facilitating 
> porting?
>  
> The following options come to mind:
>  
> 1.  Keep it an error.  It's an easy fix, adding a 0 for length.  (In my case 
> the field is only used for getting an aligned field offset.)
> 2.  Make it a warning, assume 0-size, and report this assumption and suggest 
> adding an explicit size.
> 3.  Keep it an error or warning, and have a gcc-compatibility option to 
> eliminate it.
> 4.  Silently ignore it and assume 0 size like gcc.

This is the C99 "flexible array member" feature (C99 6.7.2.1p16), which GCC 
supports as an extension in C++. Clang supports this feature for structs but 
not classes. I'm willing to support this extension for C++ classes if it shows 
up in the wild (with an Extension diagnostic of course), although it might take 
some work (of unknown scope) to ensure that such classes actually behave well 
in C++.

        - Doug
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to