<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 --- - missed optimization for static constexpr field without definition"
href="http://llvm.org/bugs/show_bug.cgi?id=17612">17612</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>missed optimization for static constexpr field without definition
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.3
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</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++11
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>bruno-llvm@defraine.net
</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>Created <span class=""><a href="attachment.cgi?id=11388" name="attach_11388" title="test case">attachment 11388</a> <a href="attachment.cgi?id=11388&action=edit" title="test case">[details]</a></span>
test case
Consider the code in attachment. clang only properly optimizes the function
`f()' when it has a definition for the constexpr field `foo' in the same
compilation unit.
Note that I'm not complaining that I have to provide a definition for field
`foo'. But my choice for the compilation unit for this definition should not
affect performance?
$ clang++ -std=c++11 -O2 -Wall -c report.cpp && objdump -d report.o
report.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <_Z1fv>:
0: b8 01 00 00 00 mov $0x1,%eax
5: 83 3d 00 00 00 00 01 cmpl $0x1,0x0(%rip) # c <_Z1fv+0xc>
c: 74 05 je 13 <_Z1fv+0x13>
e: b8 02 00 00 00 mov $0x2,%eax
13: c3 retq
$ clang++ -DDEF -std=c++11 -O2 -Wall -c report.cpp && objdump -d report.o
report.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <_Z1fv>:
0: b8 01 00 00 00 mov $0x1,%eax
5: c3 retq</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>