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

--- Comment #2 from Derek Martin <quirkygnu at bladeshadow dot org> ---
Making it private doesn't solve the issue, since the derived class can itself
still incorrectly call the private included method.  Not likely to happen in
the oversimple example I gave but perhaps more so in more complex, real-world
implementations.

As a practical matter, because the warning is (relatively) new, it's pretty
likely that (as in my case) for older existing code bases which make use of
method hiding (which again, is a perfectly valid, documented feature of C++),
the task of updating the code to skirt the warning will fall to a less-senior
maintenance engineer, to whom the option to make it private may simply not
occur...  I happened to catch the issue in a code review, but another reviewer
might not, especially given that the compiler's documentation actually
recommends solving it that way.  In fact TBH I initially approved the change,
but it kinda gnawed at me, and we eventually ended up reverting it and
disabling the warning.  It doesn't provide value in any of our projects, but
does cause a headache trying to update the numerous code bases we support to
silence the warning.

Reply via email to