public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "sshannin at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/96269] New: optional comparison with nullopt fails
Date: Tue, 21 Jul 2020 14:44:47 +0000	[thread overview]
Message-ID: <bug-96269-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 96269
           Summary: optional comparison with nullopt fails
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sshannin at gmail dot com
  Target Milestone: ---

Consider the following:

seth@dev6:~/tmp$ cat opt.cpp
#include <optional>

struct X {
  template <typename T>
  bool operator==(const T&) {
    return false;
  }
};

bool foo() {
  std::optional<X> x;
#ifndef FLIP
  return x == std::nullopt;
#else
  return std::nullopt == x;
#endif
}

With gcc 9.1.0, this compiles regardless of whether or not FLIP is defined.

With gcc 10.1.0 however, the FLIP variant does not compile.

seth@dev6:~/tmp$ /toolchain15/bin/g++ -c -o opt.o opt.cpp --std=c++20
seth@dev6:~/tmp$ /toolchain15/bin/g++ -c -o opt.o opt.cpp --std=c++20 -DFLIP
In file included from opt.cpp:1:
/toolchain15/include/c++/10.1.0/optional: In instantiation of ‘constexpr
std::__optional_relop_t<decltype ((declval<_Up>() == declval<_Tp>()))>
std::operator==(const _Up&, const std::optional<_Tp>&) [with _Tp = X; _Up =
std::nullopt_t; std::__optional_relop_t<decltype ((declval<_Up>() ==
declval<_Tp>()))> = bool; decltype ((declval<_Up>() == declval<_Tp>())) =
bool]’
...etc...

It's a tad hard for me to keep track of which overloads are supposed to
exist/how they're supposed to resolve and I think introduction of <=> was
expected to change behavior here a bit, so I'm not actually sure if this is
supposed to compile still.

seth@dev6:~/tmp$ /toolchain15/bin/g++ -v
Using built-in specs.
COLLECT_GCC=/toolchain15/bin/g++
COLLECT_LTO_WRAPPER=/toolchain15/bin/../libexec/gcc/x86_64-pc-linux-gnu/10.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc_10_1_0/configure --prefix=/toolchain15
--enable-languages=c,c++,fortran --enable-lto --disable-plugin
--program-suffix=-10.1.0 --disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.1.0 (GCC)

             reply	other threads:[~2020-07-21 14:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-21 14:44 sshannin at gmail dot com [this message]
2020-07-21 15:10 ` [Bug libstdc++/96269] " redi at gcc dot gnu.org
2020-07-21 16:17 ` sshannin at gmail dot com
2020-11-05 15:40 ` redi at gcc dot gnu.org
2020-11-05 15:52 ` ville.voutilainen at gmail dot com
2020-11-05 16:07 ` ville.voutilainen at gmail dot com
2020-11-05 16:51 ` sshannin at gmail dot com
2020-11-05 17:41 ` redi at gcc dot gnu.org
2020-11-05 17:50 ` redi at gcc dot gnu.org
2020-11-05 17:54 ` ville.voutilainen at gmail dot com
2020-11-05 18:00 ` [Bug libstdc++/96269] [10/11 Regression] " redi at gcc dot gnu.org
2020-11-05 19:09 ` cvs-commit at gcc dot gnu.org
2020-11-05 19:31 ` redi at gcc dot gnu.org
2020-11-05 19:38 ` redi at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-96269-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).