[LLVMbugs] [Bug 17990] New: may wrong code bug at -O0 level
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Nov 19 01:11:59 PST 2013
http://llvm.org/bugs/show_bug.cgi?id=17990
Bug ID: 17990
Summary: may wrong code bug at -O0 level
Product: clang
Version: 3.3
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: justmao945 at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Created attachment 11567
--> http://llvm.org/bugs/attachment.cgi?id=11567&action=edit
source
Sorry for I don't know where to post this bug, so I put it here as the "NEW".
Thanks.
Source code:
------------------------------------------
#include <ctype.h>
#include <stdio.h>
int main() {
const char* str = "abcd1234abcd12333";
for(size_t i = 0; i < 10; ++i) {
char c = str[i];
bool d = isdigit(c); // Clang store str[0] to d, volatile doesn't help
if(i < 10 && d == isdigit(str[i]) ) {
printf("%zu %c\n", i, str[i]);
}
}
return 0;
}
------------------------------------------
Compilation and run
------------------------------------------
ohio:tmp$clang -O0 bug.cc
ohio:tmp$./a.out
0 a
1 b
2 c
3 d
8 a
9 b
ohio:tmp$clang -O1 bug.cc
ohio:tmp$./a.out
0 a
1 b
2 c
3 d
4 1
5 2
6 3
7 4
8 a
9 b
--
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/20131119/fb77bf1f/attachment.html>
More information about the llvm-bugs
mailing list