<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - std::optional does not work well with std::is_convertible when used with void"
href="https://bugs.llvm.org/show_bug.cgi?id=49615">49615</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>std::optional does not work well with std::is_convertible when used with void
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</td>
</tr>
<tr>
<th>Version</th>
<td>11.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Other
</td>
</tr>
<tr>
<th>OS</th>
<td>other
</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>contact@jpboivin.me
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
</td>
</tr></table>
<p>
<div>
<pre>Hello,
libc++ seems to have an implementation of std::optional that interacts badly
with std::is_convertible when trying to detect whether void is convertible to
an std::optional in an std::enable_if context.
We encountered the issue only on platforms using std::optional from libc++.
Other implementations (libstdc++, MSVC STL, Dinkumware, STX backport) are fine.
It can be easily reproduced with this code:
<a href="https://godbolt.org/z/KPqWMz">https://godbolt.org/z/KPqWMz</a>
Here's the extracted error from Clang:
/opt/compiler-explorer/clang-11.0.1/bin/../include/c++/v1/optional:610:45:
error: cannot form a reference to 'void'
return is_constructible_v<_Tp, _Up&&> &&
^
/opt/compiler-explorer/clang-11.0.1/bin/../include/c++/v1/optional:711:47:
note: in instantiation of function template specialization
'std::__1::optional<std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char>>>::_CheckOptionalArgsConstructor::__enable_implicit<void>'
requested here
_CheckOptionalArgsCtor<_Up>::template __enable_implicit<_Up>()
^
/opt/compiler-explorer/clang-11.0.1/bin/../include/c++/v1/optional:714:15:
note: while substituting prior template arguments into non-type template
parameter [with _Up = void]
constexpr optional(_Up&& __v)
^~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/clang-11.0.1/bin/../include/c++/v1/type_traits:1739:66:
note: while substituting deduced template arguments into function template
'optional' [with _Up = void, $1 = (no value)]
: public integral_constant<bool, __is_convertible_to(_T1, _T2)> {};
^
<source>:12:24: note: in instantiation of template class
'std::__1::is_convertible<void, std::__1::optional<std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char>>>>' requested here
std::enable_if_t<!std::is_convertible<TOther, TValue>::value, int> foo(const
TValue& value)</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>