http://llvm.org/bugs/show_bug.cgi?id=12133
Bug #: 12133
Summary: if overflow is required to exit a loop clang will emit
an infinite loop
Product: clang
Version: 3.0
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
Classification: Unclassified
Created attachment 8119
--> http://llvm.org/bugs/attachment.cgi?id=8119
testcase
The following loop (see also the attached source file) only ends because i
overflows and thus finally reaches the required 0x7fffffff:
for (int i = -0x80000000; i < 0x7fffffff; i += 0x1fffff)
clang translates this into an unconditional infinite loop. If the loop body is
empty, though, clang removes the infinite loop, which is inconsistent. :)
Here's what GCC makes of it:
1: bb 01 00 20 00 mov $0x200001,%ebx
6: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)
d: 00 00 00
10: e8 00 00 00 00 callq 15 <bar()+0x15>
15: 83 eb 01 sub $0x1,%ebx
18: 75 f6 jne 10 <bar()+0x10>
And clang's infinite loop:
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: 66 66 66 2e 0f 1f 84 data32 data32 nopw %cs:0x0(%rax,%rax,1)
b: 00 00 00 00 00
10: e8 00 00 00 00 callq 15 <bar()+0x15>
15: eb f9 jmp 10 <bar()+0x10>
I would appreciate a compiler that translates the overflow correctly, but also
warns me about it. This was really a bug in my code, and thanks to this bug in
clang I found it... :)
--
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