public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/57854] New: Would like to have a warning for virtual overrides without C++11 "override" keyword
@ 2013-07-08 23:39 thiago at kde dot org
  2013-07-09  9:29 ` [Bug c++/57854] " manu at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: thiago at kde dot org @ 2013-07-08 23:39 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-01-13 15:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-08 23:39 [Bug c++/57854] New: Would like to have a warning for virtual overrides without C++11 "override" keyword thiago at kde dot org
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

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).