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