[PATCH] D23498: Left shifts of negative values are defined if -fwrapv is set
Filipe Cabecinhas via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 15 06:47:27 PDT 2016
filcab added a subscriber: filcab.
================
Comment at: test/CodeGen/wrapv-lshr-sanitize.c:1
@@ +1,2 @@
+// RUN: %clang_cc1 -fsanitize=shift-base -emit-llvm %s -o - -triple x86_64-linux-gnu -fwrapv | opt -instnamer -S | FileCheck %s
+
----------------
Do you really need `instnamer`?
================
Comment at: test/Sema/negative-shift-wrapv.c:9
@@ +8,3 @@
+ int i;
+ i = -1 << (WORD_BIT - 1); // no-warning
+}
----------------
It's a bit weird to have the test function be dead code, but I don't see a big problem anyway.
Do you need to do the whole `WORD_BIT` thing? I'd rather just shift -1 by 1 (which is already UB in non -fwrapv world, but defined in -fwrapv world).
https://reviews.llvm.org/D23498
More information about the cfe-commits
mailing list