This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/77314] New: Allows C++11 POD types in anonymous structures.
- From: "ian at geometrian dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 22 Aug 2016 02:55:33 +0000
- Subject: [Bug c++/77314] New: Allows C++11 POD types in anonymous structures.
- Authentication-results: sourceware.org; auth=none
- Auto-submitted: auto-generated
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.