]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: relax ref-qual overloading rules for C++20 [PR98939]
authorPatrick Palka <ppalka@redhat.com>
Thu, 12 Feb 2026 02:35:35 +0000 (21:35 -0500)
committerPatrick Palka <ppalka@redhat.com>
Thu, 12 Feb 2026 02:35:35 +0000 (21:35 -0500)
commitae37ade22ecf4e4ca2911d6628f8bec20c3d6422
tree0fb77e04366a8bf205d71516eb6b9c5dcecf3e7e
parent48f2e8aa6ddad72955781728bdf515eb50411d24
c++: relax ref-qual overloading rules for C++20 [PR98939]

As explained in one of Tomasz's library papers P2438R2[1], C++20 allows
ref-qualified member overloads to coexist with non-ref-qualified ones,
but at the time of writing no compiler supported that.  This patch
implements this C++20 relaxation so that we can in turn implement
P2438R2 as originally intended -- without needing to change the
signature of the main string::substr overload.

[1]: https://wg21.link/P2438R2#_modifying_existing_const_overload

PR c++/98939
PR libstdc++/119745

gcc/cp/ChangeLog:

* class.cc (object_parms_correspond): Allow differing
FUNCTION_REF_QUALIFIED in C++20.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/ref-qual5.C: Expect no diagnostics in C++20.

Reviewed-by: Jason Merrill <jason@redhat.com>
gcc/cp/class.cc
gcc/testsuite/g++.dg/cpp0x/ref-qual5.C