id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 11726,boost/spirit/home/support/detail/endian/endian.hpp:76:57: runtime error: left shift of negative value -1,davidlt,Joel de Guzman,"Boost Spirit is triggered undefined behaviour in C++. {{{ #include #include int main(void) { const unsigned char raw_bytes[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; long long result = boost::spirit::detail::load_little_endian(raw_bytes); std::cout << result << std::endl; return 0; } }}} or {{{ #include #include #include #include int main(void) { long long* p; std::size_t sz; std::tie(p, sz) = std::get_temporary_buffer(1); assert(sz != 0); boost::spirit::detail::store_little_endian(p, -1); long long result2 = boost::spirit::detail::load_little_endian(p); std::cout << result2 << std::endl; return 0; } }}} Compile: {{{ g++ -fsanitize=undefined -fno-omit-frame-pointer -g -std=c++14 -O2 test.cpp }}} Used GCC 4.9.3 in my case. Result: {{{ /usr/include/boost/spirit/home/support/detail/endian/endian.hpp:76:57: runtime error: left shift of negative value -1 /usr/include/boost/spirit/home/support/detail/endian/endian.hpp:76:57: runtime error: left shift of negative value -1 /usr/include/boost/spirit/home/support/detail/endian/endian.hpp:76:57: runtime error: left shift of negative value -1 /usr/include/boost/spirit/home/support/detail/endian/endian.hpp:76:57: runtime error: left shift of negative value -1 /usr/include/boost/spirit/home/support/detail/endian/endian.hpp:76:57: runtime error: left shift of negative value -1 /usr/include/boost/spirit/home/support/detail/endian/endian.hpp:76:57: runtime error: left shift of negative value -1 /usr/include/boost/spirit/home/support/detail/endian/endian.hpp:76:57: runtime error: left shift of negative value -1 -1 }}} Tested with Boost 1.57, but code has not been changed in master. I guess, this will trigger undefined behaviour every time a singed type is used. Reference: C++ standard 5.8 ""Shift operators"" section. From Boost: {{{ 75 static T load_little(const unsigned char* bytes) 76 { return *bytes | (next::load_little(bytes + 1) << 8); } }}}",Bugs,closed,To Be Determined,spirit,Boost 1.57.0,Problem,fixed,spirit,