https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118292
Bug ID: 118292
Summary: Erroneous 'is_standard_layout' value in derived class
with multi-level inheritance chain when
[[no_unique_address]] is involved
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: rush102333 at gmail dot com
Target Milestone: ---
$g++ -std=c++20 err.cpp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
struct E1 { }; struct E2 { };
struct A
{
[[no_unique_address]] E1 e;
};
class C : A{};
class B : C
{
[[no_unique_address]] E2 e;
};
static_assert(!__is_standard_layout (B), "");
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The test input above is able to trigger the assertion in gcc but not in clang,
EDG or MSVC.
Note that gcc will not assert if the [[no_unique_address]] specifier is
removed.
Compiler Explorer:
https://godbolt.org/z/7EPTGdGzd