public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "thiago at kde dot org" <gcc-bugzilla@gcc.gnu.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	[thread overview]
Message-ID: <bug-57854-4@http.gcc.gnu.org/bugzilla/> (raw)

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.


             reply	other threads:[~2013-07-08 23:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-08 23:39 thiago at kde dot org [this message]
2013-07-09  9:29 ` [Bug c++/57854] " manu at gcc dot gnu.org
2013-07-09  9:36 ` redi at gcc dot gnu.org
2013-07-09  9:50 ` manu at gcc dot gnu.org
2014-12-14 14:53 ` ville.voutilainen at gmail dot com
2015-01-13 15:57 ` ville.voutilainen at gmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-57854-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).