https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65143
Mikhail Maltsev <maltsevm at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |maltsevm at gmail dot com --- Comment #3 from Mikhail Maltsev <maltsevm at gmail dot com> --- This optimization is still missing in current trunk: $ cat ./test.cc struct A { int j; }; struct B : public virtual A { }; struct C final : public B { int get(); }; int C::get() { return A::j; } $ /opt/gcc-5.0.0/bin/g++ -O -std=c++11 -c -S ./test.cc -o test_gcc.s && cat ./test_gcc.s .file "test.cc" .text .align 2 .globl _ZN1C3getEv .type _ZN1C3getEv, @function _ZN1C3getEv: .LFB0: .cfi_startproc movq (%rdi), %rax movq -24(%rax), %rax movl (%rdi,%rax), %eax ret .cfi_endproc .LFE0: .size _ZN1C3getEv, .-_ZN1C3getEv .ident "GCC: (GNU) 5.0.0 20150315 (experimental)" .section .note.GNU-stack,"",@progbits (Note: optimization flags like -O3 and -fdevirtualize-speculatively don't affect this behavior; neither method calls nor data member accesses get devirtualized) $ clang++ -O -std=c++11 -c -S ./test.cc -o test_clang.s && cat ./test_clang.s .text .file "./test.cc" .globl _ZN1C3getEv .align 16, 0x90 .type _ZN1C3getEv,@function _ZN1C3getEv: # @_ZN1C3getEv .cfi_startproc # BB#0: # %entry movl 8(%rdi), %eax retq .Ltmp0: .size _ZN1C3getEv, .Ltmp0-_ZN1C3getEv .cfi_endproc .ident "clang version 3.7.0 (trunk 228487)" .section ".note.GNU-stack","",@progbits So, I can confirm it in sense "reproduce" (I don't have a right to change the status of PR)