http://llvm.org/bugs/show_bug.cgi?id=19291
Bug ID: 19291
Summary: Clang miscompiles the code with loop unrolling
(-m32/-O2)
Product: new-bugs
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: new bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
Reproduces with trunk Clang for me:
$ cat test.cc
#include <stdio.h>
#include <stdlib.h>
#include <vector>
using namespace std;
template <unsigned long bvsize>
void Test() {
vector<unsigned long> bits(bvsize);
for (unsigned long it = 0; it < 30; it++) {
for (unsigned long j = 0; j < bits.size(); j++) {
bits[j] = j;
}
for (size_t j = 0; j < bits.size(); j++) {
if (j != bits[j]) {
fprintf(stderr, "%zu:%lu\n", j, bits[j]);
abort();
}
}
}
}
int main(int argc, char **argv) {
Test<8>();
Test<16>();
Test<32>();
Test<64>();
return 0;
}
$ bin/clang -fPIC -O2 -m32 -lstdc++ test.cc && ./a.out
0:980777509
Aborted (core dumped)
The problem goes away if I remove -fPIC or -m32, or reduce the number of Test<>
instantiations.
--
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