Bug 64243 - Passing and returning structures with single member of floating type via SSE registers is wrong on Windows x86-64 ABI
Summary: Passing and returning structures with single member of floating type via SSE ...
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.9.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Keywords: ABI, wrong-code
: 86727 (view as bug list)
Depends on:
Reported: 2014-12-09 16:43 UTC by Krzysztof Surdacki
Modified: 2020-12-30 21:20 UTC (History)
2 users (show)

See Also:
Target: mingw
Known to work: 9.3.1
Known to fail: 8.4.1
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Krzysztof Surdacki 2014-12-09 16:43:27 UTC
Two types of structures:

struct TestFloat { float x; };
struct TestDouble { double x; };

are passed and returned via SSE registers which is wrong in Windows x86-64 ABI.
According to Microsoft documentation:
and code generated by MSVS2013 analysis, this kind of structures should be passed via integer registers (RCX, RDX, R8, and R9) and returned in RAX register.
Comment 1 Richard Biener 2018-07-30 09:37:37 UTC
*** Bug 86727 has been marked as a duplicate of this bug. ***
Comment 2 Bart Janssens 2018-07-30 10:05:37 UTC
Any chance that this can be upgraded to "confirmed"? Seems this has been around for a while...
Comment 3 Bart Janssens 2020-12-29 23:16:30 UTC
We are still having this issue, it now manifests in cross-compiled binaries used in the Julia ecosystem, see: https://github.com/JuliaPackaging/BinaryBuilder.jl/issues/315
Comment 4 Uroš Bizjak 2020-12-30 08:02:34 UTC
Adding CC.
Comment 5 Uroš Bizjak 2020-12-30 09:06:33 UTC
This is fixed in gcc-11:

--cut here--
struct TestFloat { float x; };
struct TestDouble { double x; };

struct TestFloat foo (struct TestFloat x) { return x; }
struct TestDouble bar (struct TestDouble x) { return x; }
--cut here--

gcc -O2:

        movl    %ecx, %eax

        movq    %rcx, %rax
Comment 6 Uroš Bizjak 2020-12-30 09:25:42 UTC
Fixed in gcc-9.
Comment 7 Bart Janssens 2020-12-30 21:20:15 UTC
Thanks, confirmed that this is also working on GCC 10.2. Unfortunately the latest in our compiler images is 9.1, and that seems to be still affected, so we'll have to upgrade.