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

Davide Italiano davide at freebsd.org
Mon Jul 27 13:19:57 PDT 2015


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;
                                     ^  ~~

--
Davide



More information about the llvm-commits mailing list