On 17 November 2015 at 10:28, Paolo Bonzini <pbonz...@redhat.com> wrote: > On 17/11/2015 11:19, Peter Maydell wrote: >> I think we should only take this patch if you can get a cast-iron >> guarantee from both clang and gcc that they will never use this >> UB to drive optimizations. As you say gcc already say this more or >> less, but clang doesn't, and if they're warning about it that to >> me suggests that they will feel freer to rely on the UB in future. > > 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. thanks -- PMM