https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93402
Bug ID: 93402 Summary: Wrong code when returning padded struct Product: gcc Version: 9.2.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: v at hnn dot net.br Target Milestone: --- Target: x86_64-pc-linux-gnu Created attachment 47698 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47698&action=edit Minimal example Output: $ gcc example.c -O3 -fno-inline $ ./a.out a.out: example.c:23: main: Assertion `output.b == 122222222222' failed. Abortado (imagem do nĂșcleo gravada) The assembly output: ``` fn: movabs rdx, 11111111111 xor eax, eax imul rdi, rdx movabs rdx, 111111111111 ret ``` Always returns ret.a = 0 and ret.b = 111111111111 This seems to be a GCC 6 regression [1] Many thanks to everyone on StackOverflow who helped me with this [2] [1]: "https://gcc.godbolt.org/z/le3EYP" [2]: "https://stackoverflow.com/questions/59871171/possible-gcc-bug-when-returning-struct-from-a-function" $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --enable-shared --enable-threads=posix --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --enable-multilib --disable-werror --enable-checking=release --enable-default-pie --enable-default-ssp --enable-cet=auto gdc_include_dir=/usr/include/dlang/gdc Thread model: posix gcc version 9.2.0 (GCC)