public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/96269] New: optional comparison with nullopt fails
@ 2020-07-21 14:44 sshannin at gmail dot com
  2020-07-21 15:10 ` [Bug libstdc++/96269] " redi at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: sshannin at gmail dot com @ 2020-07-21 14:44 UTC (permalink / raw)
  To: gcc-bugs

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)

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

end of thread, other threads:[~2020-11-05 19:38 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-21 14:44 [Bug libstdc++/96269] New: optional comparison with nullopt fails sshannin at gmail dot com
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

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).