[Bug c++/84695] New: Missed opportunity to issue warning about override

drepper.fsp+rhbz at gmail dot com gcc-bugzilla@gcc.gnu.org
Sun Mar 4 06:16:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84695

            Bug ID: 84695
           Summary: Missed opportunity to issue warning about override
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: drepper.fsp+rhbz at gmail dot com
  Target Milestone: ---

Stroustrup in [1] §20.3.4 writes the compilers should issue warnings about
inconsistent use of explicit override controls.

struct foo {
  virtual int one(int) { return 1; }
  virtual int two(int) { return 2; }
};
struct bar : foo {
  int one(int) override { return 101; }
  int two(int) { return 102; }
};
bar b;

In this case the compiler should issue a warning about bar::two.

This is different from -Wsuggest-override.  That command line option causes a
warning to be issued but the fact that bar::one uses override should
automatically turn on this type of warnings for the rest of the class.  I would
even say there is no need for a further command line option, it should just
been done.

[1] http://www.stroustrup.com/4th.html


More information about the Gcc-bugs mailing list