[LLVMbugs] [Bug 16903] New: clang misscompiles “|?===?UTF-8?Q?” if the right side is a int{char{T}}
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Aug 15 11:17:47 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=16903
Bug ID: 16903
Summary: clang misscompiles “|=” if the right side is a
int{char{T}}
Product: clang
Version: 3.3
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: florian.weber at sfz-bw.de
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
Created attachment 11041
--> http://llvm.org/bugs/attachment.cgi?id=11041&action=edit
the preprocessed source
The following program causes clang to create wrong code (plattform:
x86_64-unknown-linux-gnu):
#include <iostream>
template<typename T>
void fun (T it) {
int m = 0;
for(int i = 0; i < 4; ++i, ++it){
m |= int{char{*it}};
std::cout << int(*it) << ", " << m << ", " << i << std::endl;
}
}
int main () {
char in[4] = {0,0,0,0};
fun(in);
}
Expected output:
0, 0, 0
0, 0, 1
0, 0, 2
0, 0, 3
The real output depends on the optimization-level, eg with -O0:
0, 256, 0
0, 110578432, 1
0, 110578432, 2
0, 110578432, 3
(110578432 is a number unique to every run if adress-space-randomisation is
enabled, otherwise it is always -7936)
with -O3 the output is always:
0, 224, 0
0, 224, 1
0, 224, 2
0, 224, 3
Additional information:
My commandline is:
clang++ -O0 -std=c++11 main.cpp / clang++ -O3 -std=c++11 main.cpp
The preprocessed source is attached.
As the Bug has some (though small) similarities, it may be related to #16894.
A look into the assembler showed that the only “or”-instruction in the TU
involves the register %ecx which is not used in any other place of the
object-file (I don't known details of the x64-assembler, so this might be
unrelated but it took long enough to find and looks suspicious enough that I
note it here).
clang++ --version:
clang version 3.3 (tags/RELEASE_33/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
plattform: Arch Linux
--
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/20130815/c42fabd0/attachment.html>
More information about the llvm-bugs
mailing list