[Bug c++/93503] [9/10/11/12 Regression] Duplicated warning on pure virtual template
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Jan 7 01:44:16 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93503
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
For the reduced testcase this is what clang produces:
<source>:3:5: error: 'virtual' cannot be specified on member function templates
virtual int foo(int) = 0;
^~~~~~~~
<source>:3:17: error: illegal initializer (only variables can be initialized)
virtual int foo(int) = 0;
^
MSVC:
<source>(3): error C2898: 'int S::foo(int)': member function templates cannot
be virtual
<source>(3): error C2187: syntax error: 'constant' was unexpected here
<source>(3): note: This diagnostic occurred in the compiler generated function
'int S::foo(int)'
ICC:
<source>(3): error: "virtual" is not allowed in a function template declaration
virtual int foo(int) = 0;
^
<source>(3): error: expected a ";"
virtual int foo(int) = 0;
^
Clang's error message is incorrect even because it says only variables can be
initialized which is not true as virtual functions can be initilized to 0 so it
can be considered a pure virtual.
Maybe GCC's second error message could be changed to talk about pure virtual
and such.
More information about the Gcc-bugs
mailing list