[cfe-dev] Should adding 'final' to a C++11 class change linking behavior?
Eli Friedman
eli.friedman at gmail.com
Mon Nov 21 10:41:27 PST 2011
On Mon, Nov 21, 2011 at 10:13 AM, Jeff Walden <jwalden+clang at mit.edu> wrote:
> Should adding 'final' to a class change linking behavior?
>
> I have a class which I'd like to mark as final. Nothing inherits from it, so it should be fine to mark it as such. However, when I do so, I get a bunch of undefined-reference warnings linking code that uses pointers to that class. (The class itself is never instantiated.) My understanding was that 'final' solely prevented inheritance/overriding, and I'd think that any linking failure like this would be a bug. Is that understanding correct?
>
> Producing a reduced testcase from this situation may be tricky, so I'd like to know if I'm missing something obvious before trying to make one.
clang will optimize calls to a virtual function in a final class to
non-virtual calls. See canDevirtualizeMemberFunctionCall in
CGClass.cpp.
-Eli
More information about the cfe-dev
mailing list