id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 12162,buffer interface violates strict-aliasing rule,Vinnie Falco ,Beman Dawes,"The buffer class interfaces can cause violations of the strict-aliasing rule. This example program emits this warning when compiled with optimizations on GCC 5.1.1: {{{ #include #include #include #include template std::uint16_t get(Streambuf& sb) { using namespace boost::asio; using namespace boost::endian; std::uint8_t b[2]; sb.consume(buffer_copy(buffer(b), sb.data())); return reinterpret_cast(&b[0])->value(); } int main() { using namespace boost::asio; streambuf sb; std::uint8_t b[2]; memset(&b[0], 0, sizeof(b)); sb.commit(buffer_copy(sb.prepare(sizeof(b)), buffer(b))); return get(sb); } }}} Produces: {{{ prog.cc: In instantiation of 'uint16_t get(Streambuf&) [with Streambuf = boost::asio::basic_streambuf<>; uint16_t = short unsigned int]': prog.cc:24:18: required from here prog.cc:14:67: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] return reinterpret_cast(&b[0])->value(); }}} Link to program and output: http://melpon.org/wandbox/permlink/x7xQsxaU3jv0lOtD ",Bugs,new,To Be Determined,endian,Boost 1.60.0,Problem,,,