<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 --- - Calling `std::__bind` (a returned function object of `std::bind`) makes unnecessary instantiation of function templates"
href="http://llvm.org/bugs/show_bug.cgi?id=22003">22003</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Calling `std::__bind` (a returned function object of `std::bind`) makes unnecessary instantiation of function templates
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</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>mimomorin@gmail.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=13586" name="attach_13586" title="fix and test case">attachment 13586</a> <a href="attachment.cgi?id=13586&action=edit" title="fix and test case">[details]</a></span>
fix and test case
A function template with deduced return type needs to be instantiated to
deduce its return type. If the instantiation is ill-formed, this results in
hard errors.
This code (line 1866 in <functional>), which is evaluated when calling
`std::__bind`
(a returned function object of `std::bind`),
typename enable_if
<
is_bind_expression<_Ti>::value,
typename __invoke_of<_Ti&, _Uj...>::type
>::type
might unnecessarily instantiate `Ti`'s `operator()` and cause errors.
For example, if `Ti` is the type of `[](auto x) { return x.value; } and `Uj` is
`int`,
we get errors. Here is a full source code to get errors:
#include <functional>
struct binary_func
{
template<typename S, typename T>
void operator()(S&&, T&&) const {}
};
int main(int argc, char* argv[])
{
auto bind = std::bind(
binary_func()
, [](auto x) { return x.value; } // Note: no SFINAE
, std::placeholders::_1
);
bind(0); // Error
}
We can avoid this unnecessary instantiations by replacing `enable_if` in the
code above
with `__lazy_enable_if`.
Patch attached.</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>