[llvm-bugs] [Bug 52270] New: UBSan is inconsistent about erroring on dead code in ternary operator branches
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Oct 23 08:58:30 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=52270
Bug ID: 52270
Summary: UBSan is inconsistent about erroring on dead code in
ternary operator branches
Product: new-bugs
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: regehr at cs.utah.edu
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org
https://gcc.godbolt.org/z/WxKjWMo47
in this example program (supplied by Pascal Cuoq), UBSan should either error in
both cases, or in neither of them (I would argue that it should not error in
either case, but ymmv):
void f(int a) {
a ? 0 : 0x7fffffff + 1;
}
void g(int a) {
a ? 0 : 0 >> 32;
}
int main(void) {
f(1);
g(1);
}
instead, however, UBSan errors on the shift bug, but not on the overflowing
addition. when this program is run, this is the output we see:
/app/example.c:6:13: runtime error: shift exponent 32 is too large for 32-bit
type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /app/example.c:6:13 in
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211023/ac8932f7/attachment.html>
More information about the llvm-bugs
mailing list