[PATCH] D82617: Disable GCC's -Woverloaded-virtual, which has false positives.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 26 10:55:50 PDT 2020


sammccall added a comment.

In D82617#2117086 <https://reviews.llvm.org/D82617#2117086>, @Quuxplusone wrote:

> FWIW, I think the example you gave is **correct** for GCC to warn on.


Everything the warning says is correct, but in this pattern the polymorphic usage is the whole point of the hierarchy, the subclasses are never exposed. There's no actual danger of confusion.

> the derived class violates the Liskov substitution principle: it doesn't have an `obj.foo(42)` method.

LSP doesn't say the classes are substitutable (indeed you couldn't template over the subclasses, for example). It says that *objects* of the classes should be. And they are.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82617/new/

https://reviews.llvm.org/D82617





More information about the cfe-commits mailing list