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



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to