On Tue, 20 May 2025 at 15:17, Xi Ruoyao <xry111@xxxxxxxxxxx> wrote: > > On Tue, 2025-05-20 at 10:11 -0400, Andrew Bell via Gcc-help wrote: > > For what it's worth, C++20 defines this behavior: > > > > > > - If the destination type is signed, the value does not change if the > > source integer can be represented in the destination type. Otherwise the > > result is implementation-defined(until C++20)the unique value of the > > destination type equal to the source value modulo 2n > > where n is the number of bits used to represent the destination type(since > > C++20) (note that this is different from signed integer arithmetic > > overflow > > <https://en.cppreference.com/w/cpp/language/operator_arithmetic#Overflows>, > > which is undefined). > > This is defined even in C89 for any 2's complement target. The problem > is just Clang insists to add a sanitizer to complain about this. And insists on include the words "undefined behavior" in the output, which is JUST WRONG. https://github.com/google/sanitizers/issues/1348