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 via email to