http://llvm.org/bugs/show_bug.cgi?id=15607
Bug ID: 15607
Summary: Uninitialized register on Shift operation
Product: libraries
Version: 3.1
Hardware: PC
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: Backend: X86
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
Apple clang 4.1 (based on LLVM 3.1svn) seems to miscompile the
following C program with optimize option -O1.
$ cat test.c
int x = 0;
int main (void)
{
return ( 1 >> ( x << 8 ) ); /* should return 1 */
}
$ clang -O1 test.c
$ ./a.out
$ echo $?
0
Note that a.out may yield correct output (1) depending on
environments. This seems to happen because register "%cl" on the
"shrl" instruction is not initialized in the generated code.
pushq %rbp
Ltmp2:
.cfi_def_cfa_offset 16
Ltmp3:
.cfi_offset %rbp, -16
movq %rsp, %rbp
Ltmp4:
.cfi_def_cfa_register %rbp
movl $1, %eax
shrl %cl, %eax
popq %rbp
ret
The code may be valid for x != 0 (due to undefined behavior), but not
for x == 0.
--
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