From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D2EC03858D39; Sat, 19 Feb 2022 16:03:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D2EC03858D39 From: "julien.philippon at epitech dot eu" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/104606] New: Regression in comparison operator resolution with std::optional Date: Sat, 19 Feb 2022 16:03:27 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 11.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: julien.philippon at epitech dot eu X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Feb 2022 16:03:27 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104606 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=3D52480&action=3Dedit Preprocessed file trigering the regression This code used to compile with G++ 11.1 but does not anymore with G++ 11.2 : ``` #include #include #include struct Value : public std::variant> { using variant::variant; }; struct Comparator { template bool operator<=3D(const T &rhs) { return true; } }; int main() { auto test =3D Comparator() <=3D Value{1}; auto test2 =3D Comparator() <=3D std::make_optional(Value{1}); } ``` In GCC 11.1 the comparison correctly deduced in the two cases that the lowe= r 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 operato= r of Value, instead of using the operator of Comparator. Output from g++ -v : ``` Using built-in specs. COLLECT_GCC=3Dg++ COLLECT_LTO_WRAPPER=3D/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=3D/usr --libdir=3D/u= sr/lib --libexecdir=3D/usr/lib --mandir=3D/usr/share/man --infodir=3D/usr/share/in= fo --with-bugurl=3Dhttps://bugs.archlinux.org/ --enable-languages=3Dc,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl --with-linker-hash-style=3Dgnu --with-system-zlib --enable-__cxa_atexit --enable-cet=3Dauto --enable-checking=3Drelease --enable-clocale=3Dgnu --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=3Dlto --enable-plugin --enable-shared --enable-threads=3Dposix --disable-libssp --disable-libstdcxx-pch --disable-werror --with-build-config=3Dbootstrap-lto --enable-link-serialization=3D1 gdc_include_dir=3D/usr/include/dlang/gdc Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.2.0 (GCC) ```=