[Bug c++/93807] -std=c++2a allows to omit out-of-class declaration in template class
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Apr 22 19:54:02 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93807
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:
https://gcc.gnu.org/g:edfa7c684d329708dcee733fcb552bed9d931621
commit r10-7894-gedfa7c684d329708dcee733fcb552bed9d931621
Author: Marek Polacek <polacek@redhat.com>
Date: Tue Apr 21 18:11:33 2020 -0400
c++: Add test for c++/93807
This PR was initially accepts-invalid, but I think it's actually valid
C++20 code. My reasoning is that in C++20 we no longer require the
declaration of operator== (#if-defed in the test), because C++20's
[temp.names]/2 says "A name is also considered to refer to a template
if it is an unqualified-id followed by a < and name lookup either finds
one or more functions or finds nothing." so when we're parsing
constexpr friend bool operator==<T>(T lhs, const Foo& rhs);
we treat "operator==" as a template name, because name lookup of
"operator==" found nothing and we have an operator-function-id, which is
an unqualified-id, and it's followed by a <. So the declaration isn't
needed to treat "operator==<T>" as a template-id.
PR c++/93807
* g++.dg/cpp2a/fn-template20.C: New test.
More information about the Gcc-bugs
mailing list