From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31444 invoked by alias); 8 Jul 2013 23:39:52 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 31419 invoked by uid 48); 8 Jul 2013 23:39:47 -0000 From: "thiago at kde dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/57854] New: Would like to have a warning for virtual overrides without C++11 "override" keyword Date: Mon, 08 Jul 2013 23:39:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.8.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: thiago at kde dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-07/txt/msg00469.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57854 Bug ID: 57854 Summary: Would like to have a warning for virtual overrides without C++11 "override" keyword Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: thiago at kde dot org I would like a new (optional) warning that would point out every C++ virtual override that is done without the C++11 keyword that indicates an override. By necessity, this warning would only be permitted in C++11 mode. The keyword was added so that developers would let the compiler know when an override is intended. However, the [[base_check]] attribute was dropped from C++11 prior to standardisation, so there's no way (currently) to ask the compiler to let us know which classes are doing overrides without the keyword. This warning should be printed in the otherwise perfectly correct code: struct Base { virtual void v(); }; struct Derived: Base { virtual void v(); // warning happens here }; This warning should not be in -Wall. It should be in -Weffc++. I'll leave it up to you whether it's in -Wextra.