[Bug c++/30300] Bogus diagnostic for anonymous structs/classes

richard-gccbugzilla at metafoo dot co dot uk gcc-bugzilla@gcc.gnu.org
Tue Jun 5 17:22:00 GMT 2007



------- Comment #2 from richard-gccbugzilla at metafoo dot co dot uk  2007-06-05 17:21 -------
Points worthy of note:

1) The OP's code is legal (to my reading of the standard) but meaningless.
Private members in unnamed classes are legal, while private members in
anonymous unions are not. So technically this should be tagged as
rejects-valid.

2) If the code is made meaningful by defining a variable whose type is the
unnamed class, the incorrect diagnostic goes away:

struct A
{
  class
  {
    static int i;
    int j;
  } k;
};

3) In my opinion, it would be valuable to produce a diagnostic in the situation
of the code in comment#0, as a quality of implementation issue. I'm not sure
whether the standard requires a diagnostic here. Comeau produces an error in
this case ("declaration does not declare anything").


-- 

richard-gccbugzilla at metafoo dot co dot uk changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |richard-gccbugzilla at
                   |                            |metafoo dot co dot uk


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30300



More information about the Gcc-bugs mailing list