[llvm-bugs] [Bug 28012] New: Over-aggressive overflow elimination check with call to exit()
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Jun 5 19:53:05 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=28012
Bug ID: 28012
Summary: Over-aggressive overflow elimination check with call
to exit()
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: Loop Optimizer
Assignee: unassignedbugs at nondot.org
Reporter: eli.friedman at gmail.com
CC: atrick at apple.com, llvm-bugs at lists.llvm.org,
sanjoy at playingwithpointers.com
Classification: Unclassified
Testcase:
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
static int will_add_overflow(int a, int x) {
return a >= INT_MIN - x;
}
void f(int a, long last_value) {
if (will_add_overflow(a, 3)) {
// Leave, and don't actually do the increment, so no UB.
printf("last_value = %ld\n", last_value);
exit(0);
}
}
void (*ff)(int, long) = f;
int main() {
int a = 0;
unsigned a_u = 0;
volatile long last_value;
do {
a_u += 3;
last_value = (long) ((int) a_u);
ff(a, last_value);
a += 3;
} while (a != 46);
return 0;
}
With clang -O0, prints "last_value = -2147483647". With clang -O2, prints
nothing. (Tested on x86-64 Linux.)
Basically the same testcase as bug 27315, except that I hid the call to exit().
--
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/20160606/c9657f7d/attachment-0001.html>
More information about the llvm-bugs
mailing list