Re: Absurd declarations, and how gcc deals with them.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




----- Original Message ----- From: "Ian Lance Taylor" <iant@xxxxxxxxxx>
To: "Sisyphus" <sisyphus1@xxxxxxxxxxxxxxx>
Cc: "gcc" <gcc-help@xxxxxxxxxxx>
Sent: Saturday, October 11, 2008 4:48 PM
Subject: Re: Absurd declarations, and how gcc deals with them.


"Sisyphus" <sisyphus1@xxxxxxxxxxxxxxx> writes:

I have some auto-generated C code that contains declarations like:

   int x[0];
   int y[] = {};

What does gcc-3.x.x do with declarations like that (and why) ?

gcc supports empty arrays as an extension to the C language.  It
should reject that code if you compile with -pedantic.

Yes, you're right - if I give some leeway over the meaning of "rejection" :-)
With -pedantic I get the following warnings:

warning: ISO C forbids zero-size array `x'
warning: ISO C forbids empty initializer braces

 Empty arrays
are mainly useful as the last field of a struct.

I would think that is the *only* situation where they are useful, and Microsoft compilers allow them under that condition. But to allow them outside of structs (or at the beginning/middle of structs) seems a bit strange. Still ... if there's a C extension that allows that, then who am I to argue :-)

In any case, I'm not so sure that I should haul gcc over the coals wrt this. If there's any evil being done, then it's probably being done by the code auto-generation procedure that's coming up with these constructs.

Thanks for the reply, Ian.

Cheers,
Rob



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux