<div dir="ltr">This class doesn't meet the definition of "standard layout" due to violating the 6th bullet point:<br><br>"Has all non-static data members and bit-fields declared in the same class (either all in the derived or all in some base)"<br><br>"Foo" has one member declared in "Foo" and one member declared in its base "Base".</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Aug 13, 2021 at 9:13 AM David Barto via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><div>According to <a href="https://en.cppreference.com/w/cpp/named_req/StandardLayoutType" target="_blank">https://en.cppreference.com/w/cpp/named_req/StandardLayoutType</a>, this should report true:</div><div><br></div><font face="CourierPrime"><span style="font-style:normal">#include <iostream><br>#include <type_traits><br><br></span></font><div><font face="CourierPrime"><span style="font-style:normal">struct Base {</span></font></div><div><font face="CourierPrime"><span style="font-style:normal">  int b_a;</span></font></div><div><font face="CourierPrime"><span style="font-style:normal">};</span></font></div><div><font face="CourierPrime"><span style="font-style:normal"><br></span></font></div><div><font face="CourierPrime"><span style="font-style:normal">struct Foo : Base {</span></font></div><div><font face="CourierPrime"><span style="font-style:normal">  int a;</span></font></div><div><font face="CourierPrime"><span style="font-style:normal">};</span></font></div><div><font face="CourierPrime"><span style="font-style:normal"><br></span></font></div><div><font face="CourierPrime"><span style="font-style:normal">int main()</span></font></div><div><font face="CourierPrime"><span style="font-style:normal">{</span></font></div><div><font face="CourierPrime"><span style="font-style:normal">  std::cout << std::boolalpha;</span></font></div><div><font face="CourierPrime"><span style="font-style:normal">  std::cout << "Base  " << std::is_standard_layout<Base>::value << "\n";</span></font></div><div><font face="CourierPrime"><span style="font-style:normal">  std::cout << "Foo   " << std::is_standard_layout<Foo>::value << "\n";</span></font></div><div><font face="CourierPrime"><span style="font-style:normal">}</span></font></div><div><font face="CourierPrime"><span style="font-style:normal"><br></span></font></div><div><font face="CourierPrime"><span style="font-style:normal">1103_ clang++ -std=c++14 /tmp/XXX.cpp -o /tmp/XXX<br>1104_ /tmp/XXX<br>Base  true<br>Foo   false<br>1105_ clang++ --version<br>Apple clang version 12.0.5 (clang-1205.0.22.11)<br>Target: x86_64-apple-darwin20.5.0<br>Thread model: posix<br>InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin<br></span></font><br></div><div>Or is this just an Apple/Clang thing and I should complain to them?</div><div><br></div><div><span style="white-space:pre-wrap">    </span>David</div><div><br></div><div>David Barto | Principal Engineer<br><a href="mailto:barto@cambridgesemantics.com" target="_blank">barto@cambridgesemantics.com</a><br><br><br><br><br><br></div><br></div>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>