[Bug c++/25322] ISO compliance of defining structs in anonymous unions

2006-05-11 Thread cfranz at aldon dot com


--- Comment #4 from cfranz at aldon dot com  2006-05-11 23:27 ---
(In reply to comment #3)
> Would someone mind specifying what section of the standard this violates?  We
> have a codebase that makes heavy use of (3). 

Section 9.5.  Furthermore, I was basing cases 2, 4, and 6 on the following:
   http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#359


-- 


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



[Bug c++/25322] New: ISO compliance of defining structs in anonymous unions

2005-12-08 Thread cfranz at aldon dot com
$ cat testunion.cpp
// testunion.cpp

static union { struct n { int I2; } S2; }; // Case 1
static union { struct   { int I1; } S1; }; // Case 2

struct foo
{
   union { struct n { int I2; } S2; }; // Case 3
   union { struct   { int I1; } S1; }; // Case 4
};

void func()
{
   union { struct n { int I2; } S2; }; // Case 5
   union { struct   { int I1; } S1; }; // Case 6
}

$ g++ --version
g++ (GCC) 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ g++ -c -pedantic testunion.cpp
testunion.cpp:8: error: `struct foon' invalid; an
anonymous
 union can only have non-static data members


g++ reports an error only in Case 3, regardless of the settings of -pedantic or
-pedantic-errors, but as I understand it all six cases violate the C++
standard.  Accordingly, Comeau and xlc++ reject all six cases in strict mode,
and accept them with warnings in relaxed mode.

This behavior is consistent for at least versions 3.4.4 and 3.3.2.


-- 
   Summary: ISO compliance of defining structs in anonymous unions
   Product: gcc
   Version: 3.4.4
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: cfranz at aldon dot com


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