On 17 November 2015 at 10:37, Paolo Bonzini <pbonz...@redhat.com> wrote: > > > On 17/11/2015 11:36, Peter Maydell wrote: >> > If and when this happens we will add "-fno-strict-overflow" for clang, >> > just like we are using "-fno-strict-aliasing" already. >> >> -fno-strict-overflow in clang is AFAICT just an alias for -fwrapv. >> These options control handling of signed overflow of addition, >> subtraction and multiplication; there is nothing I can find in the >> gcc or clang docs that suggests they have any effect on shift operations. > > In the case of GCC, that's a corollary of the compiler not treating that > overflow as undefined. > > Probably the same is true for clang.
If you pass clang -fwrapv then this causes -fsanitize=undefined to no longer complain about signed integer overflows from addition. However the sanitizer will still complain about left shifts of negative values. The conclusion I draw is that clang (as per the documentation) applies fwrapv only to addition &c, not to shifts. thanks -- PMM