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: [email protected]
ReportedBy: [email protected]
CC: [email protected]
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs