Question about is_standard_layout

According to https://en.cppreference.com/w/cpp/named_req/StandardLayoutType, this should report true:

#include
#include <type_traits>

struct Base {
int b_a;
};

struct Foo : Base {
int a;
};

int main()
{
std::cout << std::boolalpha;
std::cout << "Base " << std::is_standard_layout::value << “\n”;
std::cout << "Foo " << std::is_standard_layout::value << “\n”;
}

1103_ clang++ -std=c++14 /tmp/XXX.cpp -o /tmp/XXX
1104_ /tmp/XXX
Base true
Foo false
1105_ clang++ --version
Apple clang version 12.0.5 (clang-1205.0.22.11)
Target: x86_64-apple-darwin20.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Or is this just an Apple/Clang thing and I should complain to them?

David

David Barto | Principal Engineer
barto@cambridgesemantics.com

This class doesn’t meet the definition of “standard layout” due to violating the 6th bullet point:

“Has all non-static data members and bit-fields declared in the same class (either all in the derived or all in some base)”

“Foo” has one member declared in “Foo” and one member declared in its base “Base”.