[Bug c++/81634] New: Some types are incorrectly detected as not standard layout
raskolnikov at gnu dot org
gcc-bugzilla@gcc.gnu.org
Mon Jul 31 15:30:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81634
Bug ID: 81634
Summary: Some types are incorrectly detected as not standard
layout
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: raskolnikov at gnu dot org
Target Milestone: ---
The following code fails to compile with GCC 7.1.0 when passing -std=c++17:
```
#include <type_traits>
struct a {};
struct b { int x; };
struct ca : a {};
struct cb : ca { b x; };
static_assert(std::is_standard_layout<cb>::value, "");
```
https://wandbox.org/permlink/DjuHERFFvgJg84ub
Instead of using `is_standard_layout`, we can detect the bug by using
`offsetof(cb, b)`, which incorrectly rises a warning about `cb` not being
standard layout.
It does work as expected, with -std=c++14 or with other versions of GCC.
More information about the Gcc-bugs
mailing list