[Bug c++/100997] New: [c++20] parse error when id-expression of constructor is simple-template-id
felix.morgner at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Jun 9 17:06:03 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100997
Bug ID: 100997
Summary: [c++20] parse error when id-expression of constructor
is simple-template-id
Product: gcc
Version: 11.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: felix.morgner at gmail dot com
Target Milestone: ---
Created attachment 50972
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50972&action=edit
Example source file
In C++20 mode, GCC 11.1 rejects the following code:
template<typename>
struct A;
template<>
struct A<int> {
A<int>() {}
};
With the following error:
<source>:6:12: error: expected unqualified-id before ')' token
I currently don't have access to my copy of the standard, but working from both
https://wg21.link/std and https://wg21.link/std20, I am under the expression
that this code should be valid since:
According to [class.ctor], the sole id-expression of the ptr-declarator of the
ctors function declarator may be the injected-class-name. [class.pre] tells us
that the class-name of the class being declared is injected into scope of the
class, where it is called the injected-class-name. Moreover, [class.pre]
defines a class-name to be either an indentifier or a simnple-template-id. I
would argue that in the case of the explicit specialization above, A<int> would
be a simple-template-id and thus a valid injected-class-name.
The error does not occur in C++17 mode or in GCC prior to version 11.
Tested in all cases with "-Wall -Wextra -Werror -pedantic-errors"
More information about the Gcc-bugs
mailing list