id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 12183,GCC 6.1 thinks boost::container::string violates strict aliasing,tavianator@…,Ion Gaztañaga,"The following simple test case aborts when built with -O2, but works fine with -fno-strict-aliasing. {{{ $ cat foo.cpp #include #include #include using boost::container::string; struct foo { __attribute__((noinline)) foo(string str) : m_str{std::move(str)}, m_len{m_str.length()} { } string m_str; std::size_t m_len; }; int main() { foo f{""the quick brown fox jumps over the lazy dog""}; if (f.m_len == 0) { std::abort(); } return 0; } $ g++ -O2 -Wall foo.cpp -o foo && ./foo [1] 6375 abort (core dumped) ./foo }}} I reported this as [https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71002 GCC bug 71002] but I'm not sure that the code is actually correct. It seems to at least access a non-active union member (the is_short bitfield). There may be other aliasing issues with the union -- in some cases it seems GCC wants you to access the members through the union directly, not through a pointer to a union member; see [https://gcc.gnu.org/bugzilla/show_bug.cgi?id=14319 GCC bug 14319] for example.",Bugs,closed,To Be Determined,container,Boost 1.61.0,Problem,fixed,,