<div dir="ltr"><div class="gmail_default" style="font-family:courier new,monospace;font-size:large">I have the following code:<br><br>#include <stdint.h><br><br>struct RTI {<br>char name[16];<br><br>struct bits {<br>        uint8_t u : 1;<br>        uint8_t k : 1;<br>        uint32_t pad : 30;<br>};<br><br>union {<br>        uint32_t all_bits;<br>        bits     my_bits;<br>        static_assert(sizeof(my_bits) == sizeof(all_bits), "Wrong number of bits");<br>};<br><br>};<br><br></div><div class="gmail_default" style="font-family:courier new,monospace;font-size:large">Ubuntu 14's clang 3.4 fails to compile this:<br><br>$ /usr/bin/clang++ -v -std=c++11 stass.cc<br>Ubuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4)<br>Target: x86_64-pc-linux-gnu<br>Thread model: posix<br>...<br>stass.cc:15:9: error: anonymous union can only contain non-static data members<br>        static_assert(sizeof(my_bits) == sizeof(all_bits), "Wrong number of bits");<br>        ^<br>1 error generated.<br><br></div><div class="gmail_default" style="font-family:courier new,monospace;font-size:large">However, ToT clang version 5.0.0 (trunk 294435), and every GCC version I've thrown at it (4.8, 5.3, 6.3, 7.0) compiles it fine.<br><br></div><div class="gmail_default" style="font-family:courier new,monospace;font-size:large">Does anybody know which version fixed this? (<a href="http://godbolt.org">godbolt.org</a> suggests 3.5)<br><br></div><div class="gmail_default" style="font-family:courier new,monospace;font-size:large">I looked in Bugzilla, but all I could find was <a href="https://bugs.llvm.org//show_bug.cgi?id=12515">https://bugs.llvm.org//show_bug.cgi?id=12515</a> (new and unassigned since 2012).<br></div><div class="gmail_default" style="font-family:courier new,monospace;font-size:large"><br></div><div class="gmail_default" style="font-family:courier new,monospace;font-size:large">Csaba<br clear="all"></div><br>-- <br><div class="gmail_signature">GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++<br>The Tao of math: The numbers you can count are not the real numbers.<br>Life is complex, with real and imaginary parts.<br>"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds<br>"People disagree with me. I just ignore them." -- Linus Torvalds<br><br></div>
</div>