[LLVMbugs] [Bug 23011] New: miscompile of % in loop
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Mar 24 16:46:31 PDT 2015
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: unassignedclangbugs at nondot.org
Reporter: nlewycky at google.com
CC: llvmbugs at cs.uiuc.edu
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 at ducttape:~$ clang++ -O2 a.cc -o a
nlewycky at ducttape:~$ ./a
2 ab
nlewycky at ducttape:~$ clang++ a.cc -o a
nlewycky at ducttape:~$ ./a
2 abab
The -O0 result is correct.
--
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/20150324/d1c592ff/attachment.html>
More information about the llvm-bugs
mailing list