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.

Reply via email to