This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/67184] New: Missed optimization with C++11 final specifier
- From: "gpderetta at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 11 Aug 2015 17:51:20 +0000
- Subject: [Bug c++/67184] New: Missed optimization with C++11 final specifier
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67184
Bug ID: 67184
Summary: Missed optimization with C++11 final specifier
Product: gcc
Version: 5.2.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: gpderetta at gmail dot com
Target Milestone: ---
struct V {
virtual void foo();
};
struct wV final : V {
};
struct oV final : V {
void foo();
};
void call(V& x)
{
x.foo();
}
void call(wV& x)
{
x.foo();
}
void call(oV& x)
{
x.foo();
}
# compile with g++ -O3 -std=c++11
gcc 5.1 and 5.2 on x86-64 generate:
call(V&):
movq (%rdi), %rax
jmp *(%rax)
call(wV&):
movq (%rdi), %rax
jmp *(%rax)
call(oV&):
jmp oV::foo()
I would expect call(wV&) to generate the same code as call(oV&).
FWIW Clang generates the expected code since about 3.5.