[compiler-rt] r243241 - tsan: fix shift overflow

Benjamin Kramer benny.kra at gmail.com
Mon Jul 27 13:29:46 PDT 2015


> On 27.07.2015, at 22:19, Davide Italiano <davide at freebsd.org> wrote:
> 
> On Mon, Jul 27, 2015 at 1:00 PM, Dmitry Vyukov <dvyukov at google.com> wrote:
>> I miserably failed to acknowledge the right tool. I did not run it
>> under ubsan. It is a new gcc warning that caught it:
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67009
>> 
> 
> For what it's worth Clang has the same very warning -- but it's not
> able to cathc your specific case. I'll open a bug for that.
> 
> % cat shift.c
> #include <sys/types.h>
> 
> static const uint32_t kFlagSync  = 2 << 30;
> static const uint32_t kFlagSync2 = 1 << 35;
> 
> % ./clang shift.c -Wshift-overflow
> shift.c:4:38: warning: shift count >= width of type [-Wshift-count-overflow]
> static const uint32_t kFlagSync2 = 1 << 35;

-Wshift-sign-overflow catches this, but it's not enabled at -Wall or -Wextra.

- Ben





More information about the llvm-commits mailing list