public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/94565] New: C++20: Comparing comparison category types against 0/nullptr is not noexcept
@ 2020-04-11 21:27 daniel.kruegler at googlemail dot com
  2020-04-13 20:25 ` [Bug libstdc++/94565] " 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 21:27 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94565
           Summary: C++20: Comparing comparison category types against
                    0/nullptr is not noexcept
           Product: gcc
           Version: 10.0
            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 should be accepted, but is rejected due to a violation of
the static_assertion:

Compiler options:

-Wall -Wextra -pedantic "-std=c++20"

//---------------------
#include <compare>

int main()
{
  static_assert(noexcept(std::partial_ordering::less == 0));
}
//---------------------

prog.cc: In function 'int main()':
prog.cc:5:17: error: static assertion failed
    5 |   static_assert(noexcept(std::partial_ordering::less == 0));
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The corresponding comparison functions for are all declared as noexcept
([cmp.partialord], [cmp.weakord], [cmp.strongord]), so the clear intention is
that such an comparison should be observable as non-throwing operations. The
reason why above test fails for all of the existing mixed comparison functions
of all the three comparison category types against 0/nullptr is caused by the
fact that the implementation-internal type std::__cmp_cat::__unspec in header
<compare> misses to declare its converting constructor as noexcept:

struct __unspec
    {
      constexpr __unspec(__unspec*) { }
    };

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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-11 21:27 [Bug libstdc++/94565] New: C++20: Comparing comparison category types against 0/nullptr is not noexcept daniel.kruegler at googlemail dot com
2020-04-13 20:25 ` [Bug libstdc++/94565] " redi at gcc dot gnu.org
2020-04-14 10:43 ` cvs-commit at gcc dot gnu.org
2020-04-14 10:44 ` 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).