<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><span class="vcard"><a class="email" href="mailto:richard-llvm@metafoo.co.uk" title="Richard Smith <richard-llvm@metafoo.co.uk>"> <span class="fn">Richard Smith</span></a>
</span> changed
<a class="bz_bug_link
bz_status_RESOLVED bz_closed" title="RESOLVED INVALID - user-defined conversion function allows cast to reference" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D24131&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=eCPFLyXK7oWFOTUzN2ceGXcjygq5tbt3R_qsY-HdzaQ&s=-ii97ZjwGOHgJzZ4Q6zK5z1GOb1g8hmy2Gb_hhDyvYI&e=">bug 24131</a>
<br>
<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>What</th>
<th>Removed</th>
<th>Added</th>
</tr>
<tr>
<td style="text-align:right;">Status</td>
<td>NEW
</td>
<td>RESOLVED
</td>
</tr>
<tr>
<td style="text-align:right;">CC</td>
<td>
</td>
<td>richard-llvm@metafoo.co.uk
</td>
</tr>
<tr>
<td style="text-align:right;">Resolution</td>
<td>---
</td>
<td>INVALID
</td>
</tr></table>
<p>
<div>
<b><a class="bz_bug_link
bz_status_RESOLVED bz_closed" title="RESOLVED INVALID - user-defined conversion function allows cast to reference" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D24131-23c2&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=eCPFLyXK7oWFOTUzN2ceGXcjygq5tbt3R_qsY-HdzaQ&s=dbSrDF_z7hwK3i8tSBC6BymLR-EwyswZJuIb9biMQ70&e=">Comment # 2</a>
on <a class="bz_bug_link
bz_status_RESOLVED bz_closed" title="RESOLVED INVALID - user-defined conversion function allows cast to reference" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D24131&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=eCPFLyXK7oWFOTUzN2ceGXcjygq5tbt3R_qsY-HdzaQ&s=-ii97ZjwGOHgJzZ4Q6zK5z1GOb1g8hmy2Gb_hhDyvYI&e=">bug 24131</a>
from <span class="vcard"><a class="email" href="mailto:richard-llvm@metafoo.co.uk" title="Richard Smith <richard-llvm@metafoo.co.uk>"> <span class="fn">Richard Smith</span></a>
</span></b>
<pre>[expr.static.cast]p4: "An expression e can be explicitly converted to a type T
using a static_cast of the form static_cast<T>(e) if the declaration T t(e); is
well-formed, for some invented temporary variable t (8.5)."
Thus we can reduce to a testcase not involving static_cast:
struct B {};
struct S { explicit operator B(); };
B const &t(S{});
... which GCC and EDG reject, and Clang still accepts. And the above testcase
is valid:
Per 8.5.3/5.2.1.2, the relevant rules for selecting conversion functions are
those in 13.3.1.6, not those in 13.3.1.5.
Per 13.3.1.6, "For direct-initialization, those explicit conversion functions
that are not hidden within S and yield type “lvalue reference to cv2 T2” or
“cv2 T2” or “rvalue reference to cv2 T2”, respectively, where T2 is the same
type as T or can be converted to type T with a qualification conversion (4.4),
are also candidate functions."
So the explicit conversion operator is considered here, and both the
initialization and the static_cast are permitted.</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>