D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 13707 - msvc32 C++ struct return ABI not followed for structs with constructors
Summary: msvc32 C++ struct return ABI not followed for structs with constructors
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P1 major
Assignee: No Owner
URL:
Keywords: pull, wrong-code
Depends on:
Blocks:
 
Reported: 2014-11-10 12:55 UTC by yebblies
Modified: 2015-02-18 03:39 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description yebblies 2014-11-10 12:55:58 UTC

    
Comment 1 yebblies 2014-11-10 12:57:51 UTC
This struct is passed in registers by dmd, while dmc++ (and presumably msvc) returns it on the stack, causing crash.  Adding a dtor 'fixes' it.

struct Prot
{
    int kind;
    void *pkg;
    extern(D) this(int kind)
    {
        this.kind = kind;
        this.pkg = null;
    }
    // ~this()
    // {
    // }
}

extern(C++) Prot func();

void main()
{
    auto p = func();
}
Comment 3 github-bugzilla 2014-11-10 14:45:42 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/69a5745cdb2077936423920cc56c8e5a5934d1d7
Fix Issue 13707 - msvc32 C++ struct return ABI not followed for structs with constructors

A constructor should stop a struct from being passed in registers on win32/C++.

https://github.com/D-Programming-Language/dmd/commit/452cfcc1f20c505f5844a993c6731839325e5e63
Merge pull request #4124 from yebblies/issue13707

[DDMD] Issue 13707 - msvc32 C++ struct return ABI not followed for structs with constructors
Comment 4 github-bugzilla 2015-02-18 03:39:26 UTC
Commits pushed to 2.067 at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/69a5745cdb2077936423920cc56c8e5a5934d1d7
Fix Issue 13707 - msvc32 C++ struct return ABI not followed for structs with constructors

https://github.com/D-Programming-Language/dmd/commit/452cfcc1f20c505f5844a993c6731839325e5e63
Merge pull request #4124 from yebblies/issue13707