This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Variables whose types are anonymous structs, once again


On May 19, 2004, at 12:09 PM, law@redhat.com wrote:

In message <83960454-89A5-11D8-8C46-000A95BCF344@apple.com>, Matt Austern write
s:
OK, I raised this issue once before.  I know more now than I did then,
so I'm raising it again.

The mainline C++ compiler gives an error (a pedwarn, which is treated
as an error by default) if you do this:
  enum { a } x;
[ ... ]
Did this ever get resolved one way or the other?  There's a ton of C++
code which trips over these kinds of things and it'd be good to know if
we need to pester those projects to get their code fixed or not.

I now believe that this code is clearly legal. The standards committee explicitly considered this case and decided not to make it illegal.

I also believe that this code is on slightly thin ice.  There are some
constructs that are very similar but that are illegal.  I suspect, also,
that "enum { a } x;" will probably be made illegal in a future version
of the standard.  So we might want to consider warning about this.

But for the moment, in the existing standard, this is legal.  The fact
that we give an error message is a compiler bug.

--Matt


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]