From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 25E543858412; Fri, 7 Jan 2022 01:44:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 25E543858412 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/93503] [9/10/11/12 Regression] Duplicated warning on pure virtual template Date: Fri, 07 Jan 2022 01:44:16 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: unknown X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 9.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: 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: Fri, 07 Jan 2022 01:44:16 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D93503 --- Comment #3 from Andrew Pinski --- For the reduced testcase this is what clang produces: :3:5: error: 'virtual' cannot be specified on member function templ= ates virtual int foo(int) =3D 0; ^~~~~~~~ :3:17: error: illegal initializer (only variables can be initialize= d) virtual int foo(int) =3D 0; ^ MSVC: (3): error C2898: 'int S::foo(int)': member function templates cann= ot be virtual (3): error C2187: syntax error: 'constant' was unexpected here (3): note: This diagnostic occurred in the compiler generated funct= ion 'int S::foo(int)' ICC: (3): error: "virtual" is not allowed in a function template declara= tion virtual int foo(int) =3D 0; ^ (3): error: expected a ";" virtual int foo(int) =3D 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 s= o it can be considered a pure virtual. Maybe GCC's second error message could be changed to talk about pure virtual and such.=