[cfe-dev] [Warnings] final class with virtual functions

Piotr Padlewski via cfe-dev cfe-dev at lists.llvm.org
Thu Dec 22 10:11:39 PST 2016


2016-12-22 19:00 GMT+01:00 Jared Grubb <jared.grubb at gmail.com>:

> -others because I'm unsure :)
>
> Arent there some forms of RTTI that are not available unless you have a
> virtual function? I swear i ran into a case where I added virtual functions
> to a class solely because I needed it to behave well in a place where RTTI
> was used.
>
> Jared
>
> + Rest
That's a valid concern, I am not really sure. But does it make sense to use
RTTI on "static" classes like this?
I never worked on code base that would use RTTI, it was always some hand
crafted solutions, so I am not really familiar with this problem.

Piotr


> El dic. 21, 2016, a las 17:24, Piotr Padlewski via cfe-dev <
> cfe-dev at lists.llvm.org> escribió:
>
> Hi,
> I was wondering if we should warn about cases like this:
>
> *struct* A final {
>
>    *virtual* *int* foo () {*return* 42;}
>
>    // virtual doesn't make any sense because it is final base class
>
> };
>
>
> or
>
>
> *struct* A {
>
>   *virtual* *int* foo () final {*return* 42;}
>
>   // the same thing
>
> };
>
>
> So in both cases it sounds like a bug, specially in the first case.
>
> I don't see any resonable cases where this code would make sense (what you
> could not achieve with override keyword).
>
>
>
> If emiting warning in these cases make sense, dibs on that feature.
>
>
> Piotr
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161222/cf9d3771/attachment.html>


More information about the cfe-dev mailing list