public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mizvekov at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-64384-4-RxTArADhBx@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-64384-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64384

Matheus Izvekov <mizvekov at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mizvekov at gmail dot com

--- Comment #7 from Matheus Izvekov <mizvekov at gmail dot com> ---
So this is still a problem in GCC 10.1.

Per
https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention?view=vs-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 
GetCPUDescriptorHandleForHeapStart( void) = 0;
```

Returned aggregate is just a boxed SIZE_T:
```
typedef struct D3D12_CPU_DESCRIPTOR_HANDLE { SIZE_T ptr; }  
D3D12_CPU_DESCRIPTOR_HANDLE;
```

So it should be possible to return on register, but instead here is code from
that method (MASM syntax, taken from D3D12.dll):
```
CDescriptorHeap::GetCPUDescriptorHandleForHeapStart:
00007FF83AD6A3F0  mov         rax,qword ptr [rcx+0D0h]  
00007FF83AD6A3F7  mov         qword ptr [rdx],rax
00007FF83AD6A3FA  mov         rax,rdx  
00007FF83AD6A3FD  ret  
```

  parent reply	other threads:[~2020-06-15  2:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-23 13:39 [Bug target/64384] New: " mity at morous dot org
2014-12-23 13:55 ` [Bug target/64384] " jacek at codeweavers dot com
2014-12-23 14:42 ` ktietz at gcc dot gnu.org
2014-12-30 23:09 ` daniel.c.klauer at web dot de
2014-12-30 23:45 ` mity at morous dot org
2014-12-31 16:25 ` daniel.c.klauer at web dot de
2020-06-15  2:20 ` mizvekov at gmail dot com [this message]
2022-12-28  9:50 ` alvinhochun at gmail dot com
2022-12-28 10:02 ` alvinhochun at gmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-64384-4-RxTArADhBx@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).