public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/104606] New: Regression in comparison operator resolution with std::optional
@ 2022-02-19 16:03 julien.philippon at epitech dot eu
  2022-02-19 16:07 ` [Bug libstdc++/104606] " julien.philippon at epitech dot eu
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: julien.philippon at epitech dot eu @ 2022-02-19 16:03 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104606
           Summary: Regression in comparison operator resolution with
                    std::optional
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: julien.philippon at epitech dot eu
  Target Milestone: ---

Created attachment 52480
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52480&action=edit
Preprocessed file trigering the regression

This code used to compile with G++ 11.1 but does not anymore with G++ 11.2 :

```
#include <optional>
#include <variant>
#include <vector>

struct Value : public std::variant<int, std::vector<Value>> {
    using variant::variant;
};

struct Comparator {
    template <typename T>
    bool operator<=(const T &rhs)
    {
        return true;
    }
};

int main()
{
    auto test = Comparator() <= Value{1};
    auto test2 = Comparator() <= std::make_optional(Value{1});
}
```

In GCC 11.1 the comparison correctly deduced in the two cases that the lower or
equal operator of Comparator should be used, but in GCC 11.2, the second
comparison which involve an optional fails to compile.

It looks like GCC is trying to instantiate the three-way comparison operator of
Value, instead of using the operator of Comparator.

Output from g++ -v :

```
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib
--libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl
--with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit
--enable-cet=auto --enable-checking=release --enable-clocale=gnu
--enable-default-pie --enable-default-ssp --enable-gnu-indirect-function
--enable-gnu-unique-object --enable-linker-build-id --enable-lto
--enable-multilib --enable-pgo-build=lto --enable-plugin --enable-shared
--enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-werror --with-build-config=bootstrap-lto
--enable-link-serialization=1 gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.0 (GCC)
```

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

end of thread, other threads:[~2024-05-02 14:17 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-19 16:03 [Bug libstdc++/104606] New: Regression in comparison operator resolution with std::optional julien.philippon at epitech dot eu
2022-02-19 16:07 ` [Bug libstdc++/104606] " julien.philippon at epitech dot eu
2022-02-19 22:17 ` [Bug c++/104606] [11/12 Regression] comparison operator resolution with std::optional and -std=c++20 pinskia at gcc dot gnu.org
2022-02-19 22:38 ` jakub at gcc dot gnu.org
2022-02-19 22:46 ` jakub at gcc dot gnu.org
2022-02-19 22:59 ` [Bug libstdc++/104606] [10/11/12 " pinskia at gcc dot gnu.org
2022-02-20  7:38 ` jakub at gcc dot gnu.org
2022-02-20  7:45 ` jakub at gcc dot gnu.org
2022-02-21  9:47 ` rguenth at gcc dot gnu.org
2022-02-21 21:01 ` redi at gcc dot gnu.org
2022-06-28 10:48 ` [Bug libstdc++/104606] [10/11/12/13 " jakub at gcc dot gnu.org
2023-07-07 10:42 ` [Bug libstdc++/104606] [11/12/13/14 " rguenth at gcc dot gnu.org
2024-03-27 20:58 ` redi at gcc dot gnu.org
2024-03-27 21:41 ` redi at gcc dot gnu.org
2024-03-27 23:11 ` redi at gcc dot gnu.org
2024-04-03 10:53 ` cvs-commit at gcc dot gnu.org
2024-05-02 14:16 ` [Bug libstdc++/104606] [11/12/13 " cvs-commit at gcc dot gnu.org
2024-05-02 14:16 ` [Bug libstdc++/104606] [11/12 " 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).