<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><span class="vcard"><a class="email" href="mailto:Casey@Carter.net" title="Casey Carter <Casey@Carter.net>"> <span class="fn">Casey Carter</span></a>
</span> changed
<a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - Class no longer convertible after declaration member of type std::function<Class()>"
href="https://bugs.llvm.org/show_bug.cgi?id=32072">bug 32072</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>Casey@Carter.net
</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 - Class no longer convertible after declaration member of type std::function<Class()>"
href="https://bugs.llvm.org/show_bug.cgi?id=32072#c3">Comment # 3</a>
on <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - Class no longer convertible after declaration member of type std::function<Class()>"
href="https://bugs.llvm.org/show_bug.cgi?id=32072">bug 32072</a>
from <span class="vcard"><a class="email" href="mailto:Casey@Carter.net" title="Casey Carter <Casey@Carter.net>"> <span class="fn">Casey Carter</span></a>
</span></b>
<pre>This is not a bug in clang: it's a defect in the specification of
std::function's conversion constructor template that I worked around in the
MSVC STL in August of 2017. It is fixed in the current release of VS2017.
In detail: std::function<T(Args...)> has a conversion constructor template that
accepts an argument of any type that is callable with Args... and returns a
type that is convertible to T.
At the closing brace in the definition of:
struct B {
std::function<C()> f;
};
the compiler is required to generate the implicitly-defined copy constructor
for B. To determine if that copy constructor should be deleted, it performs
overload resolution to determine if each of the members of B is copy
constructible. For f, that means it must determine if an object of type
std::function<C()> can be initialized from an lvalue expression of type const
std::function<C()>.
There are two candidate constructors for that initialization: std::function's
implicitly-defined copy constructor, and its conversion constructor template.
To determine if the conversion constructor template is viable it has to check
the constraints:
* "Can I call a std::function<C(Args...)> with Args...?" Yes.
* "Is the return type C convertible to C?" If implemented with
is_convertible_v<C, C>, which we do, results in undefined behavior when C is an
incomplete type.
We now guard the conversion constructor template against being used for copy
and move construction. I suspect the other Standard Libraries do as well, but
that behavior isn't guaranteed by 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>