[LLVMbugs] [Bug 9481] New: Bad loop idiom memset transform
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Mar 14 19:10:02 PDT 2011
http://llvm.org/bugs/show_bug.cgi?id=9481
Summary: Bad loop idiom memset transform
Product: new-bugs
Version: unspecified
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: new bugs
AssignedTo: unassignedbugs at nondot.org
ReportedBy: sharparrow1 at yahoo.com
CC: llvmbugs at cs.uiuc.edu
a.c:
void bar();
int foo() {
char a[10];
int i;
for (i = 0; i < 1000000; i++) {
bar();
a[i] = 23;
}
for (i = 1; i < 1000000; i++) {
bar();
a[i] += a[i-1];
}
return a[2]+a[6];
}
b.c:
#include <stdlib.h>
#include <stdio.h>
int foo();
void bar() { exit(0); }
int main() {
foo();
}
$ clang a.c b.c -O2
$ ./a.out
Segmentation fault
The issue here is that a million element memset is inserted before the first
loop, when clearly the array does not contain that many elements. Issue found
by inspection.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list