http://llvm.org/bugs/show_bug.cgi?id=20039
Bug ID: 20039
Summary: Constructing std::function from empty compatible
std::function results in half-empty state
Product: libc++
Version: unspecified
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
Created attachment 12657
--> http://llvm.org/bugs/attachment.cgi?id=12657&action=edit
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:
> 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.
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.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs