This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Anonymous types and [basic.link] for nonlocal variables
- From: Joe Buck <Joe dot Buck at synopsys dot COM>
- To: Matt Austern <austern at apple dot com>
- Cc: Geoff Keating <geoffk at apple dot com>,gcc mailing list <gcc at gcc dot gnu dot org>
- Date: Tue, 9 Mar 2004 14:47:25 -0800
- Subject: Re: Anonymous types and [basic.link] for nonlocal variables
- References: <4340E2AA-7219-11D8-8C94-000A95AA5E5E@apple.com>
On Tue, Mar 09, 2004 at 02:29:43PM -0800, Matt Austern wrote:
> Geoff checked in a patch a few days ago,
> http://gcc.gnu.org/ml/gcc-patches/2004-03/msg00346.html
>
> Among other things, this patch enforces the rule that variables with
> linkage may not be defined in terms of names with no linkage.
> Previously we enforced that rule selectively: we made a special
> exception for anonymous types. That is, we used to allow things like
> enum { foo } e;
> or
> struct { int x; int y; } pairs[] = { { 1,2 }, { 5,8 } };
>
> I didn't notice this patch when it went by a few days ago. Now I'm
> wondering if it's a good idea. Allowing variables to be defined in
> terms of anonymous types was a deliberate decision (there was a comment
> in the code pointing it out), because forms like this are legal in C
> and common, albeit illegal, in C++. If we're going to reverse a
> deliberate decision, we should make sure to give it a little thought.
>
> This is one of those annoying problems where in one sense this is
> clearly a correct change: it brings us into closer conformance with the
> language standard that we claim to implement. On the other hand, it
> breaks the QT build. I bet QT isn't alone.
In my view, anything that breaks QT is a regression, no matter how
many standards documents we can point to as justification. Certainly
-pedantic should object to such usage, and perhaps future QT versions
should avoid such usage if possible, but we need to build QT.