<html>
<head>
<base href="https://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 --- - Bug when moving from one side of a ternary operator." href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D24227&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=OIirbHb8pu8yyPNDwAm5Gm_yUuhIC1jKRzeHKd-WR_k&s=sHlNrnQcr6AKggpiAHmPg4U2YkL7ZcweQ7-HVn7iC6Y&e=">24227</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Bug when moving from one side of a ternary operator.
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.6
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</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>terrelln@umich.edu
</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>#include <iostream>
#include <utility>
struct printer {
printer() { }
printer(const printer&) { std::cout << "copy" << std::endl; }
printer(printer&&) { std::cout << "move" << std::endl; }
printer(const printer&&) { std::cout << "const rvalue ref" << std::endl; }
};
int main() {
const printer fst;
printer snd;
false ? fst : std::move(snd); // Prints: const rvalue ref
}
The ternary operator should move out of snd into a temporary according to the
standard.
See:
<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__stackoverflow.com_questions_31577762_moving-2Dout-2Dof-2Done-2Dside-2Dof-2Da-2Dternary-2Doperator&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=OIirbHb8pu8yyPNDwAm5Gm_yUuhIC1jKRzeHKd-WR_k&s=hdeojQRhkg9tm7p9ZWgwaFAuaRI-ZqX2mc83JBFkgdQ&e=">http://stackoverflow.com/questions/31577762/moving-out-of-one-side-of-a-ternary-operator</a>
and section 5.16.3 of the standard.</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>