https://bugs.llvm.org/show_bug.cgi?id=43640
Bug ID: 43640
Summary: `final` does not cause devirtualization of nested
calls
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected],
[email protected]
Consider the example:
struct A {
virtual int f() { return 0; }
virtual int g() { return f() + 40; }
};
struct B2 final : A {
int g() override;
};
int B2::g() { return A::g(); }
`B2` is final, so any call to the virtual functions of `A` end up with a call
to the same function in `B2`. So `B2::g()` should inline the `A::g()` and get
optimized to:
int B2::g() { return B2::f() + 40; }
Which is just 40, because `B2::f()` always returns 0.
Godbolt playground: https://godbolt.org/z/skqgH8
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs