https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77314

Harald van Dijk <harald at gigawatt dot nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |harald at gigawatt dot nl

--- Comment #1 from Harald van Dijk <harald at gigawatt dot nl> ---
The error comes from gcc/cp/decl.c and is preceded by the comment:

  /* Anonymous aggregates cannot have fields with ctors, dtors or complex
     assignment operators (because they cannot have these methods themselves).
     For anonymous unions this is already checked because they are not allowed
     in any union, otherwise we have to check it.  */

This comment seems outdated: C++11+ anonymous unions can have such fields, and
GCC correctly implements this. Errors for such anonymous unions are only issued
with -std=c++03/-std=gnu++03.

For anonymous structs, clang issues this error message too only in C++03 modes,
not in C++11+ modes. Perhaps GCC needs to follow that and let this diagnostic
be conditional on the language version too.

A workaround for current GCC versions is to use an array of size 1.

Reply via email to