Anonymous types and [basic.link] for nonlocal variables
Joe Buck
Joe.Buck@synopsys.COM
Tue Mar 9 22:47:00 GMT 2004
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.
More information about the Gcc
mailing list