D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2648 - Unnecessary struct ABI inconsistency
Summary: Unnecessary struct ABI inconsistency
Status: RESOLVED DUPLICATE of issue 2385
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 All
: P2 normal
Assignee: No Owner
URL:
Keywords: spec
Depends on:
Blocks: 2385 3105
  Show dependency treegraph
 
Reported: 2009-02-06 04:40 UTC by Don
Modified: 2014-02-15 13:13 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Don 2009-02-06 04:40:34 UTC
There is a horrible ABI difference between Linux and Windows which seems to be completely unjustified. Although extern(C) needs to be different between the systems, there's no reason for extern(D) to.

Linux and Windows should use the same return algorithm for 1,2,4, and 8-byte structs. This is the only point at which the ABI differs (except for the fact that real.sizeof is different, but that's something dictacted by the OS).

---
# For Windows, 1, 2 and 4 byte structs are returned in EAX.
# For Windows, 8 byte structs are returned in EDX,EAX, where EDX gets the most significant half.
# For other struct sizes, the return value is stored through a hidden pointer passed as an argument to the function.
---
Comment 1 Neia Neutuladh 2009-04-25 15:25:05 UTC
The ABI as implemented in DMD with regards to returning structs appears to be as the spec describes for Windows, as confirmed by mucking about with obj2asm. (Note that, to create a 3-byte struct, you need to use align(1).)

I ascertained this using dmd2.029; other versions might have different behavior.
Comment 2 Walter Bright 2010-11-08 01:03:29 UTC

*** This issue has been marked as a duplicate of issue 2385 ***