<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Incorrect code gen for global const ref"
href="http://llvm.org/bugs/show_bug.cgi?id=16263">16263</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Incorrect code gen for global const ref
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Macintosh
</td>
</tr>
<tr>
<th>OS</th>
<td>MacOS X
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>a.bataev@gmx.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>clang incorrectly translates the next code:
const unsigned ii = 0xdeadbeaf;
const int& dd = (const int&) ii;
int main(void) {
return (ii == dd) ? 0: 1;
}
clang produces the following llvm-code:
; ModuleID = 'test.cpp'
target datalayout =
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.8.0"
@dd = global i32* null, align 8
@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()*
} { i32 65535, void ()* @_GLOBAL__I_a }]
define internal void @__cxx_global_var_init() section
"__TEXT,__StaticInit,regular,pure_instructions" {
entry:
%ref.tmp = alloca i32, align 4
store i32 -559038801, i32* %ref.tmp, align 4
store i32* %ref.tmp, i32** @dd, align 8
ret void
}
define i32 @main() nounwind uwtable ssp {
entry:
%retval = alloca i32, align 4
store i32 0, i32* %retval
%0 = load i32** @dd, align 8
%1 = load i32* %0, align 4
%cmp = icmp eq i32 -559038801, %1
%cond = select i1 %cmp, i32 0, i32 1
ret i32 %cond
}
define internal void @_GLOBAL__I_a() section
"__TEXT,__StaticInit,regular,pure_instructions" {
entry:
call void @__cxx_global_var_init()
ret void
}
The cope for @dd initialization in @__cxx_global_var_init is incorrect.
Alexey Bataev
Software Engineer
Intel Compiler Team
Intel Corp.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>