https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117610

--- Comment #3 from Alejandro Colomar <alx at kernel dot org> ---
(In reply to Xi Ruoyao from comment #2)
> No, it *is* initializing a pointer.  You cannot initialize a struct with 0. 
> Instead the initializer is considered "flattened" in C.
> 
> For example:
> 
> struct s2 {
>       int  *x;
>       int y;
> };
> 
> int t;
> 
> int
> main(void)
> {
>       struct s2  a2[] = {0, 1, &t, 2};
>       _Static_assert(sizeof(a2) == sizeof(struct s2) * 2);
> }

Ahhh, you're right.  That's shown in EXAMPLE 5 (p29) in
<https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf#subsection.6.7.11>.
 (I'm not sure which of the weird paragraphs specify this exactly.)

How about adding a diagnostic for flat initializers?  :-)

Reply via email to