https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88479
--- Comment #3 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> --- (In reply to Jakub Jelinek from comment #2) > Note, it is no longer implementation-defined behavior in C++20, but well > defined: > > "Otherwise, the result is the unique value of the destination type that is > congruent to the source integer modulo 2^N, where N is the range exponent of > the destination type.", see wg21.link/p1236 . It wouldn't surprise me if > next C standard changes similarly. The C standard would have to drop ones' complement and sign-magnitude first. In any case, this is not a good programming practice, and for some projects, it is reasonable to avoid such cases (a function to do such a conversion explicitly would have been a better choice). So, a new feature in the sanitizer would be a good thing, just like -Werror=... can make the compilation of valid programs fail but is useful to detect bugs.