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

            Bug ID: 77314
           Summary: Allows C++11 POD types in anonymous structures.
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ian at geometrian dot com
  Target Milestone: ---

Consider the following in >= C++11:

  #include <type_traits>
  struct MyType {
      int val;
      MyType(void) = default;
      MyType(int v) : val(v) {}
  }; static_assert(std::is_pod<MyType>::value,"");

This POD type cannot be used in an anonymous structure.  E.g.:

  /* "error: member 'MyType Wrapper::<anonymous struct>::t' with constructor
not allowed in anonymous aggregate" */
  struct Wrapper { struct { MyType t; }; };

GCC is not required by standard to support anonymous structures at all (it need
only support unnamed structures), but since it does, it seems strange to limit
it in this way (it is unclear what conditions are disallowed, even).  This
enhancement would relax the rules for anonymous structures, allowing any POD
type.

Reply via email to