[Bug c++/98625] UBSAN: gcc/cp/module.cc:977:15: runtime error: left shift of negative value -1
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jan 19 20:10:29 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98625
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Note, -1 << x shifts are well defined in C++20 (assuming x < sizeof (int) *
CHAR_BIT), but isn't well defined in older C++ versions. For C++11 .. C++17
in particular, x << y is UB if x < 0 or ((unsigned) x >> (sizeof (int) *
CHAR_BIT - 1 - y)) > 1 (in addition to the usual y < 0 or y >= sizeof (int) *
CHAR_BIT).
More information about the Gcc-bugs
mailing list