[Bug c++/15938] New: ICE with anonymous unions

reichelt at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Fri Jun 11 12:24:00 GMT 2004


The following code is accepted by the C frontend, but the C++ frontend
segfaults (since gcc 2.95.x).

===================================
typedef union
{
    struct { int i; };
    struct { char c; };
} A;

A a = { 0 };
===================================

bug.cc:7: error: union `A' with no named members cannot be initialized
bug.cc:7: internal compiler error: Segmentation fault
Please submit a full bug report, [etc.]

Apart from the segfault, should the code be accepted by the C++ frontend
as well or should it be rejected as it is now?

BTW, the PR was inspired by a question on the gcc mailing list:
http://gcc.gnu.org/ml/gcc/2004-06/msg00158.html

-- 
           Summary: ICE with anonymous unions
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Keywords: ice-on-invalid-code
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: reichelt at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


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



More information about the Gcc-bugs mailing list