https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67345
Bug ID: 67345 Summary: -Woverloaded-virtual false negative: Does not warn on overloaded virtual function Product: gcc Version: unknown Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: EisahLee at gmx dot de Target Milestone: --- Created attachment 36251 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36251&action=edit Example program to demonstrate missing warning. See example program in attachment. Crucial steps to reproduce code that exhibits the bug: 'MyDerived' defines 'virtual frob(int, int)', and hides the non-virtual 'frob(int)' of 'MyBase'. Evidence that there is actually some "hiding" going on: - Empirical: If we change 'frob(int)' of 'MyBase' to virtual, then g++ issues a warning. - Reported on stackoverflow, other people ran into that issue before me: http://stackoverflow.com/a/6035884/3070326 Expected behaviour from g++: Warn that 'MyDerived::frob(int,int)' hides 'MyBase::frob(int)', although this might be unintuitive for C++ newbies. (Just like the warning for "a < b < c".) Actual behaviour: 'frob(int)' is inaccessible when the static type is 'MyDerived'. This means one of the following happens: - If 'frob(int)' is not called, then g++ silently ignores the situation. BAD! I want a warning, telling me that 'frob(int, int)' is at fault. (Example: Attached file, verbatim) - Otherwise, g++ only lists 'MyDerived::frob(int, int)' as candidate. BAD! I want another candidate ('MyBase::frob(int)') with the explanation that overload resolution does not operate across namespaces. (Example: Attached file, with the 'derived.frob(23);' uncommented.) Meta-info: "gcc version 4.9.3 (Debian 4.9.3-3) " As there is no similar bug report, I assume it has not been fixed by a more recent version anyway.