[Bug libstdc++/94562] New: C++20: std::shared_ptr<int>{} <=> nullptr ill-formed
daniel.kruegler at googlemail dot com
gcc-bugzilla@gcc.gnu.org
Sat Apr 11 19:04:06 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94562
Bug ID: 94562
Summary: C++20: std::shared_ptr<int>{} <=> nullptr ill-formed
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: daniel.kruegler at googlemail dot com
Target Milestone: ---
The following program (using -Wall -Wextra -std=c++2a -pedantic) is rejected:
#include <memory>
bool ok = std::shared_ptr<int>{} <=> nullptr;
int main()
{
}
with the following diagnostics:
>>>>>>>>>>>>>>>>>>>>>>
prog.cc:3:34: error: no match for 'operator<=>' (operand types are
'std::shared_ptr<int>' and 'std::nullptr_t')
3 | bool ok = std::shared_ptr<int>{} <=> nullptr;
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
In file included from
/opt/wandbox/gcc-head/include/c++/10.0.1/bits/stl_algobase.h:67,
from /opt/wandbox/gcc-head/include/c++/10.0.1/memory:63,
from prog.cc:1:
/opt/wandbox/gcc-head/include/c++/10.0.1/bits/stl_iterator.h:474:5: note:
candidate: 'template<class _IteratorL, class _IteratorR> requires
three_way_comparable_with<_IteratorR, _IteratorL, std::partial_ordering>
constexpr std::compare_three_way_result_t<_IteratorL, _IteratorR>
std::operator<=>(const std::reverse_iterator<_IteratorL>&, const
std::reverse_iterator<_IteratorR>&)' (reversed)
474 | operator<=>(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/opt/wandbox/gcc-head/include/c++/10.0.1/bits/stl_iterator.h:474:5: note:
template argument deduction/substitution failed:
prog.cc:3:38: note: mismatched types 'const
std::reverse_iterator<_IteratorL>' and 'std::nullptr_t'
3 | bool ok = std::shared_ptr<int>{} <=> nullptr;
| ^~~~~~~
In file included from
/opt/wandbox/gcc-head/include/c++/10.0.1/bits/stl_algobase.h:67,
from /opt/wandbox/gcc-head/include/c++/10.0.1/memory:63,
from prog.cc:1:
/opt/wandbox/gcc-head/include/c++/10.0.1/bits/stl_iterator.h:1433:5: note:
candidate: 'template<class _IteratorL, class _IteratorR> requires
three_way_comparable_with<_IteratorR, _IteratorL, std::partial_ordering>
constexpr std::compare_three_way_result_t<_IteratorL, _IteratorR>
std::operator<=>(const std::move_iterator<_IteratorL>&, const
std::move_iterator<_IteratorR>&)' (reversed)
1433 | operator<=>(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/opt/wandbox/gcc-head/include/c++/10.0.1/bits/stl_iterator.h:1433:5: note:
template argument deduction/substitution failed:
prog.cc:3:38: note: mismatched types 'const std::move_iterator<_IteratorL>'
and 'std::nullptr_t'
3 | bool ok = std::shared_ptr<int>{} <=> nullptr;
| ^~~~~~~
In file included from /opt/wandbox/gcc-head/include/c++/10.0.1/ranges:45,
from
/opt/wandbox/gcc-head/include/c++/10.0.1/bits/ranges_algobase.h:38,
from
/opt/wandbox/gcc-head/include/c++/10.0.1/bits/ranges_uninitialized.h:36,
from /opt/wandbox/gcc-head/include/c++/10.0.1/memory:69,
from prog.cc:1:
/opt/wandbox/gcc-head/include/c++/10.0.1/optional:1036:5: note: candidate:
'template<class _Tp, class _Up> requires three_way_comparable_with<_Up, _Tp,
std::partial_ordering> constexpr std::compare_three_way_result_t<_IteratorL,
_IteratorR> std::operator<=>(const std::optional<_Tp>&, const
std::optional<_Up>&)' (reversed)
1036 | operator<=>(const optional<_Tp>& __x, const optional<_Up>& __y)
| ^~~~~~~~
/opt/wandbox/gcc-head/include/c++/10.0.1/optional:1036:5: note: template
argument deduction/substitution failed:
prog.cc:3:38: note: mismatched types 'const std::optional<_Tp>' and
'std::nullptr_t'
3 | bool ok = std::shared_ptr<int>{} <=> nullptr;
| ^~~~~~~
In file included from /opt/wandbox/gcc-head/include/c++/10.0.1/ranges:45,
from
/opt/wandbox/gcc-head/include/c++/10.0.1/bits/ranges_algobase.h:38,
from
/opt/wandbox/gcc-head/include/c++/10.0.1/bits/ranges_uninitialized.h:36,
from /opt/wandbox/gcc-head/include/c++/10.0.1/memory:69,
from prog.cc:1:
/opt/wandbox/gcc-head/include/c++/10.0.1/optional:1051:5: note: candidate:
'template<class _Tp> constexpr std::strong_ordering std::operator<=>(const
std::optional<_Tp>&, std::nullopt_t)' (reversed)
1051 | operator<=>(const optional<_Tp>& __x, nullopt_t) noexcept
| ^~~~~~~~
/opt/wandbox/gcc-head/include/c++/10.0.1/optional:1051:5: note: template
argument deduction/substitution failed:
prog.cc:3:38: note: mismatched types 'const std::optional<_Tp>' and
'std::nullptr_t'
3 | bool ok = std::shared_ptr<int>{} <=> nullptr;
| ^~~~~~~
In file included from /opt/wandbox/gcc-head/include/c++/10.0.1/ranges:45,
from
/opt/wandbox/gcc-head/include/c++/10.0.1/bits/ranges_algobase.h:38,
from
/opt/wandbox/gcc-head/include/c++/10.0.1/bits/ranges_uninitialized.h:36,
from /opt/wandbox/gcc-head/include/c++/10.0.1/memory:69,
from prog.cc:1:
/opt/wandbox/gcc-head/include/c++/10.0.1/optional:1186:5: note: candidate:
'template<class _Tp, class _Up> constexpr
std::compare_three_way_result_t<_IteratorL, _IteratorR> std::operator<=>(const
std::optional<_Tp>&, const _Up&)' (reversed)
1186 | operator<=>(const optional<_Tp>& __x, const _Up& __v)
| ^~~~~~~~
/opt/wandbox/gcc-head/include/c++/10.0.1/optional:1186:5: note: template
argument deduction/substitution failed:
prog.cc:3:38: note: mismatched types 'const std::optional<_Tp>' and
'std::nullptr_t'
3 | bool ok = std::shared_ptr<int>{} <=> nullptr;
| ^~~~~~~
In file included from /opt/wandbox/gcc-head/include/c++/10.0.1/ranges:46,
from
/opt/wandbox/gcc-head/include/c++/10.0.1/bits/ranges_algobase.h:38,
from
/opt/wandbox/gcc-head/include/c++/10.0.1/bits/ranges_uninitialized.h:36,
from /opt/wandbox/gcc-head/include/c++/10.0.1/memory:69,
from prog.cc:1:
/opt/wandbox/gcc-head/include/c++/10.0.1/tuple:1425:5: note: candidate:
'template<class ... _Tps, class ... _Ups> constexpr
std::common_comparison_category_t<std::__detail::__synth3way_t<_Tps, _Ups>...>
std::operator<=>(const std::tuple<_Tps ...>&, const std::tuple<_UTypes ...>&)'
(reversed)
1425 | operator<=>(const tuple<_Tps...>& __t, const tuple<_Ups...>& __u)
| ^~~~~~~~
/opt/wandbox/gcc-head/include/c++/10.0.1/tuple:1425:5: note: template
argument deduction/substitution failed:
prog.cc:3:38: note: mismatched types 'const std::tuple<_Tps ...>' and
'std::nullptr_t'
3 | bool ok = std::shared_ptr<int>{} <=> nullptr;
| ^~~~~~~
In file included from /opt/wandbox/gcc-head/include/c++/10.0.1/memory:83,
from prog.cc:1:
/opt/wandbox/gcc-head/include/c++/10.0.1/bits/unique_ptr.h:893:5: note:
candidate: 'template<class _Tp, class _Dp, class _Up, class _Ep> requires
three_way_comparable_with<typename std::unique_ptr<_Tp, _Dp>::pointer, typename
std::unique_ptr<_Up, _Ep>::pointer, std::partial_ordering>
std::compare_three_way_result_t<typename std::unique_ptr<_Tp, _Dp>::pointer,
typename std::unique_ptr<_Up, _Ep>::pointer> std::operator<=>(const
std::unique_ptr<_Tp, _Dp>&, const std::unique_ptr<_Up, _Ep>&)' (reversed)
893 | operator<=>(const unique_ptr<_Tp, _Dp>& __x,
| ^~~~~~~~
/opt/wandbox/gcc-head/include/c++/10.0.1/bits/unique_ptr.h:893:5: note:
template argument deduction/substitution failed:
prog.cc:3:38: note: mismatched types 'const std::unique_ptr<_Tp, _Dp>' and
'std::nullptr_t'
3 | bool ok = std::shared_ptr<int>{} <=> nullptr;
| ^~~~~~~
In file included from /opt/wandbox/gcc-head/include/c++/10.0.1/memory:83,
from prog.cc:1:
/opt/wandbox/gcc-head/include/c++/10.0.1/bits/unique_ptr.h:900:5: note:
candidate: 'template<class _Tp, class _Dp> requires
three_way_comparable<typename std::unique_ptr<_Tp, _Dp>::pointer,
std::partial_ordering> std::compare_three_way_result_t<typename
std::unique_ptr<_Tp, _Dp>::pointer> std::operator<=>(const std::unique_ptr<_Tp,
_Dp>&, std::nullptr_t)' (reversed)
900 | operator<=>(const unique_ptr<_Tp, _Dp>& __x, nullptr_t)
| ^~~~~~~~
/opt/wandbox/gcc-head/include/c++/10.0.1/bits/unique_ptr.h:900:5: note:
template argument deduction/substitution failed:
prog.cc:3:38: note: mismatched types 'const std::unique_ptr<_Tp, _Dp>' and
'std::nullptr_t'
3 | bool ok = std::shared_ptr<int>{} <=> nullptr;
| ^~~~~~~
In file included from
/opt/wandbox/gcc-head/include/c++/10.0.1/bits/stl_algobase.h:64,
from /opt/wandbox/gcc-head/include/c++/10.0.1/memory:63,
from prog.cc:1:
/opt/wandbox/gcc-head/include/c++/10.0.1/bits/stl_pair.h:472:5: note:
candidate: 'template<class _T1, class _T2> constexpr
std::common_comparison_category_t<decltype
(std::__detail::__synth3way(declval<_T1&>(), declval<_T1&>())), decltype
(std::__detail::__synth3way(declval<_T2&>(), declval<_T2&>()))>
std::operator<=>(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)'
472 | operator<=>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/opt/wandbox/gcc-head/include/c++/10.0.1/bits/stl_pair.h:472:5: note:
template argument deduction/substitution failed:
prog.cc:3:38: note: 'std::shared_ptr<int>' is not derived from 'const
std::pair<_T1, _T2>'
3 | bool ok = std::shared_ptr<int>{} <=> nullptr;
| ^~~~~~~
In file included from
/opt/wandbox/gcc-head/include/c++/10.0.1/bits/ios_base.h:46,
from /opt/wandbox/gcc-head/include/c++/10.0.1/streambuf:41,
from
/opt/wandbox/gcc-head/include/c++/10.0.1/bits/streambuf_iterator.h:35,
from /opt/wandbox/gcc-head/include/c++/10.0.1/iterator:66,
from
/opt/wandbox/gcc-head/include/c++/10.0.1/bits/ranges_algobase.h:36,
from
/opt/wandbox/gcc-head/include/c++/10.0.1/bits/ranges_uninitialized.h:36,
from /opt/wandbox/gcc-head/include/c++/10.0.1/memory:69,
from prog.cc:1:
/opt/wandbox/gcc-head/include/c++/10.0.1/system_error:244:3: note: candidate:
'std::strong_ordering std::operator<=>(const std::error_code&, const
std::error_code&)'
244 | operator<=>(const error_code& __lhs, const error_code& __rhs)
noexcept
| ^~~~~~~~
/opt/wandbox/gcc-head/include/c++/10.0.1/system_error:244:33: note: no known
conversion for argument 1 from 'std::shared_ptr<int>' to 'const
std::error_code&'
244 | operator<=>(const error_code& __lhs, const error_code& __rhs)
noexcept
| ~~~~~~~~~~~~~~~~~~^~~~~
/opt/wandbox/gcc-head/include/c++/10.0.1/system_error:368:3: note: candidate:
'std::strong_ordering std::operator<=>(const std::error_condition&, const
std::error_condition&)'
368 | operator<=>(const error_condition& __lhs,
| ^~~~~~~~
/opt/wandbox/gcc-head/include/c++/10.0.1/system_error:368:38: note: no known
conversion for argument 1 from 'std::shared_ptr<int>' to 'const
std::error_condition&'
368 | operator<=>(const error_condition& __lhs,
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
In file included from /opt/wandbox/gcc-head/include/c++/10.0.1/tuple:39,
from /opt/wandbox/gcc-head/include/c++/10.0.1/ranges:46,
from
/opt/wandbox/gcc-head/include/c++/10.0.1/bits/ranges_algobase.h:38,
from
/opt/wandbox/gcc-head/include/c++/10.0.1/bits/ranges_uninitialized.h:36,
from /opt/wandbox/gcc-head/include/c++/10.0.1/memory:69,
from prog.cc:1:
/opt/wandbox/gcc-head/include/c++/10.0.1/array:259:5: note: candidate:
'template<class _Tp, long unsigned int _Nm> constexpr
std::__detail::__synth3way_t<_T1> std::operator<=>(const std::array<_Tp, _Nm>&,
const std::array<_Tp, _Nm>&)'
259 | operator<=>(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
| ^~~~~~~~
/opt/wandbox/gcc-head/include/c++/10.0.1/array:259:5: note: template argument
deduction/substitution failed:
prog.cc:3:38: note: 'std::shared_ptr<int>' is not derived from 'const
std::array<_Tp, _Nm>'
3 | bool ok = std::shared_ptr<int>{} <=> nullptr;
| ^~~~~~~
1
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
The problem is due to a Standard library specification problem, see
https://cplusplus.github.io/LWG/issue3427
More information about the Gcc-bugs
mailing list