<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 --- - Constructing std::function from empty compatible std::function results in half-empty state"
href="http://llvm.org/bugs/show_bug.cgi?id=20039">20039</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Constructing std::function from empty compatible std::function results in half-empty state
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>kaballo86@hotmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu, mclow.lists@gmail.com
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=12657" name="attach_12657" title="proposed fix">attachment 12657</a> <a href="attachment.cgi?id=12657&action=edit" title="proposed fix">[details]</a></span>
proposed fix
Constructing an `std::function` from an instance of `std::function` with a
compatible signature fails to meet the precondition when the source argument is
empty:
<span class="quote">> template<class F> function(F f);
> Postconditions: !*this if any of the following hold:
> — F is an instance of the function class template, and !f.</span >
int main() {
std::function<double(double)> f;
std::function<float(double)> g = f;
std::function<double(float)> h = f;
std::function<float(float)> i = f;
assert(!f);
assert(!g); // fails
assert(!h); // fails
assert(!i); // fails
}
This results in a half-empty state of sorts, where the wrapper isn't empty but
invoking it will result in invoking an empty wrapper.
This is due to a typo in `function::__not_null`, resulting in an overload for
`std::function` that has a non-deducible template parameter and thus isn't a
candidate for overload resolution. This applies to both the variadic and
non-variadic definitions. The non-variadic definition for a nullary function is
also missing an overload for function pointers.</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>