[PATCH] diagnosing flexible array assignments

Eli Friedman eli.friedman at gmail.com
Thu Sep 12 14:26:21 PDT 2013


On Thu, Sep 12, 2013 at 12:58 PM, Aaron Ballman <aaron at aaronballman.com>wrote:

> So declarations are a bit more hairy.  It seems that GCC allows static
> initalization of flexible array members as an extension:
> http://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html


We don't support that extension. :)  And if we did, we could just not warn
on declarations using that extension.


>
> Also, the C standard itself shows a declaration of a value type using
> a flexible array member (granted, it is to show what could be
> undefined behavior):
>
> 6.7.2.1p19 (ISO/IEC 9899:2011):
>
> struct s { int n; double d[]; };
> struct s t1 = { 0 }; // valid
> struct s t2 = { 1, { 4.2 }}; // invalid
> t1.n = 4; // valid
> t1.d[0] = 4.2; // might be undeļ¬ned behavior
>

I don't think this indicates anything.

-Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130912/3bee2c29/attachment.html>


More information about the cfe-commits mailing list