public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/94562] New: C++20: std::shared_ptr<int>{} <=> nullptr ill-formed
@ 2020-04-11 19:04 daniel.kruegler at googlemail dot com
  2020-04-11 19:05 ` [Bug libstdc++/94562] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2020-04-11 19:04 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libstdc++/94562] C++20: std::shared_ptr<int>{} <=> nullptr ill-formed
  2020-04-11 19:04 [Bug libstdc++/94562] New: C++20: std::shared_ptr<int>{} <=> nullptr ill-formed daniel.kruegler at googlemail dot com
@ 2020-04-11 19:05 ` redi at gcc dot gnu.org
  2020-04-14 20:55 ` cvs-commit at gcc dot gnu.org
  2020-04-14 22:51 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2020-04-11 19:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94562

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
No, it's because that operator isn't implemented yet.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libstdc++/94562] C++20: std::shared_ptr<int>{} <=> nullptr ill-formed
  2020-04-11 19:04 [Bug libstdc++/94562] New: C++20: std::shared_ptr<int>{} <=> nullptr ill-formed daniel.kruegler at googlemail dot com
  2020-04-11 19:05 ` [Bug libstdc++/94562] " redi at gcc dot gnu.org
@ 2020-04-14 20:55 ` cvs-commit at gcc dot gnu.org
  2020-04-14 22:51 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-04-14 20:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94562

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:f5fa62ed19a1c85cda920bbe05eb075d8f2a0b42

commit r10-7725-gf5fa62ed19a1c85cda920bbe05eb075d8f2a0b42
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Apr 14 21:54:55 2020 +0100

    libstdc++: Add comparison operators to std::shared_ptr (PR 94562)

    This also implements the proposed resolution to LWG issue 3247, so that
    the ill-formed <=> expression with nullptr is not used.

            PR libstdc++/94562
            * include/bits/shared_ptr.h (operator<=>): Define for C++20.
            * include/bits/shared_ptr_base.h (operator<=>): Likewise.
            * include/bits/unique_ptr.h (operator<=>): Add inline specifier.
            * testsuite/20_util/shared_ptr/comparison/cmp_c++20.cc: New test.
            * testsuite/20_util/shared_ptr/comparison/less.cc: Do not expect
            std::less<A*> to be used when comparing std::shared_ptr<A> objects
in
            C++20.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libstdc++/94562] C++20: std::shared_ptr<int>{} <=> nullptr ill-formed
  2020-04-11 19:04 [Bug libstdc++/94562] New: C++20: std::shared_ptr<int>{} <=> nullptr ill-formed daniel.kruegler at googlemail dot com
  2020-04-11 19:05 ` [Bug libstdc++/94562] " redi at gcc dot gnu.org
  2020-04-14 20:55 ` cvs-commit at gcc dot gnu.org
@ 2020-04-14 22:51 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2020-04-14 22:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94562

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |10.0
         Resolution|---                         |FIXED
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
<=> for shared_ptr has now been implemented.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-04-14 22:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-11 19:04 [Bug libstdc++/94562] New: C++20: std::shared_ptr<int>{} <=> nullptr ill-formed daniel.kruegler at googlemail dot com
2020-04-11 19:05 ` [Bug libstdc++/94562] " redi at gcc dot gnu.org
2020-04-14 20:55 ` cvs-commit at gcc dot gnu.org
2020-04-14 22:51 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).