https://llvm.org/bugs/show_bug.cgi?id=23011
Bug ID: 23011
Summary: miscompile of % in loop
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
$ clang++ -v
clang version 3.7.0 (trunk 233044)
Target: x86_64-unknown-linux-gnu
Testcase:
#include <stdio.h>
#include <stdlib.h>
#include <string>
using namespace std;
int main(int argc, char **argv) {
int r = 2;
bool ok = true;
while (ok) {
string ab;
for (int i = 0; i < r % 3; i++) {
ab += "ab";
}
printf("%d %s\n", r, ab.c_str());
r++;
ok = (r < 3);
}
}
nlewycky@ducttape:~$ clang++ -O2 a.cc -o a
nlewycky@ducttape:~$ ./a
2 ab
nlewycky@ducttape:~$ clang++ a.cc -o a
nlewycky@ducttape:~$ ./a
2 abab
The -O0 result is correct.
--
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