From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0D4CB3851C1A; Mon, 15 Jun 2020 02:20:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0D4CB3851C1A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1592187630; bh=MA5apK8hYncfSM9L9uzv7gTXAe3TjAWFYfUNpuINhg0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=gwnKSRMosvtYkGRoyG1joicoZxJBFWRhw8uPjoCHjkWFUiEaZ2JMc2nSZ6/H2XFtM wr7+B6GW/YYujM905PGLzgzNleRG5VNX9dvW8aquIyZKgea/5Kej8kbKc6Tj+rNEHg WF+lCAP9ZFRgmlWIZglFT6kzJRD1bel5A7xn4YLs= From: "mizvekov at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/64384] mingw-w64: stdcall function returning an aggregate is incompatible with MS ABI Date: Mon, 15 Jun 2020 02:20:29 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 4.9.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mizvekov at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Jun 2020 02:20:30 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D64384 Matheus Izvekov changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mizvekov at gmail dot com --- Comment #7 from Matheus Izvekov --- So this is still a problem in GCC 10.1. Per https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention?view=3Dvs= -2019 What GCC does would be correct according to that spec. But in practice, MSVC does different, and windows DLLs expect what MSVC does. So I have stumbled on this problem with D3D12, calling GetCPUDescriptorHandleForHeapStart method on ID3D12DescriptorHeap object. Here is definition of this method from SDK: ``` virtual D3D12_CPU_DESCRIPTOR_HANDLE STDMETHODCALLTYPE=20 GetCPUDescriptorHandleForHeapStart( void) =3D 0; ``` Returned aggregate is just a boxed SIZE_T: ``` typedef struct D3D12_CPU_DESCRIPTOR_HANDLE { SIZE_T ptr; }=20=20 D3D12_CPU_DESCRIPTOR_HANDLE; ``` So it should be possible to return on register, but instead here is code fr= om that method (MASM syntax, taken from D3D12.dll): ``` CDescriptorHeap::GetCPUDescriptorHandleForHeapStart: 00007FF83AD6A3F0 mov rax,qword ptr [rcx+0D0h]=20=20 00007FF83AD6A3F7 mov qword ptr [rdx],rax 00007FF83AD6A3FA mov rax,rdx=20=20 00007FF83AD6A3FD ret=20=20 ```=