[cfe-dev] Question about is_standard_layout

David Barto via cfe-dev cfe-dev at lists.llvm.org
Fri Aug 13 09:12:55 PDT 2021


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

#include <iostream>
#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<Base>::value << "\n";
  std::cout << "Foo   " << std::is_standard_layout<Foo>::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 at cambridgesemantics.com






-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20210813/e218af1a/attachment.html>


More information about the cfe-dev mailing list