Anonymous types and [basic.link] for nonlocal variables

Matt Austern austern@apple.com
Tue Mar 9 22:30:00 GMT 2004


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 principle we'd be 
within our rights to tell developers that they need to fix their code, 
but I'm not convinced they'd thank us for it.

Is this change something we want?

			--Matt



More information about the Gcc mailing list