http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61082
Bug ID: 61082 Summary: [x86-64 Itanium ABI] g++ uses wrong return location for class with head padding Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: greened at obbligato dot org Created attachment 32745 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32745&action=edit Testcase gcc appears to use the wrong sequence for returning an object with head padding. For the attached testcase, gcc -O2 generates the following code for function foo: .globl _Z3fooR1Y .type _Z3fooR1Y, @function _Z3fooR1Y: .LFB1019: .cfi_startproc movq 8(%rdi), %rax ret .cfi_endproc The class Y should be classified INTEGER under the x86-64 ABI. It has eight bytes of head padding because it inherits from an empty base class and has a member that also inherits from the same empty base class. By my reading of the ABI, foo should return the Y object in (RAX, RDX), with RDX containing the meaningful bits (the long value). The Intel compiler generates the code I would expect for this testcase.