[Bug target/95676] [armhf] g++ mis-compiles code at -O1 or above
acoplan at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jun 23 14:34:04 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95676
Alex Coplan <acoplan at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution|--- |INVALID
--- Comment #4 from Alex Coplan <acoplan at gcc dot gnu.org> ---
Looks like the program has undefined behavior (signed integer overflow), so not
a compiler bug.
$ cat test.cc
#include <msgpack.hpp>
bool check_equality()
{
std::chrono::system_clock::time_point
v(std::chrono::system_clock::time_point::min());
msgpack::zone z;
msgpack::object obj(v, z);
return obj.as<std::chrono::system_clock::time_point>() == v;
}
int main()
{
return check_equality() ? 42 : 0;
}
$ g++ test.cc -fsanitize=undefined -I msgpack-c/include/ -I boost_1_73_0
$ ./a.out
/usr/include/c++/7/chrono:176:38: runtime error: signed integer overflow:
-9223372037 * 1000000000 cannot be represented in type 'long int'
/usr/include/c++/7/chrono:379:8: runtime error: signed integer overflow:
9223372036709551616 + 145224192 cannot be represented in type 'long int'
I get the same result with clang++ as well.
More information about the Gcc-bugs
mailing list