Jump to page: 1 2 3
Thread overview
[Issue 16243] wrong C++ argument passing with empty struct and 6 integers
Jul 06, 2016
Martin Nowak
Jul 07, 2016
Martin Nowak
Jul 24, 2016
Martin Nowak
Jul 24, 2016
kinke@gmx.net
Jul 27, 2016
Walter Bright
Jul 27, 2016
Jacob Carlborg
Sep 12, 2016
Martin Nowak
Sep 12, 2016
Jacob Carlborg
Sep 12, 2016
Jacob Carlborg
Sep 14, 2016
Joakim
Sep 19, 2016
Brad Roberts
Sep 19, 2016
Jacob Carlborg
May 20, 2017
Joakim
May 20, 2017
Jacob Carlborg
Feb 24, 2018
Walter Bright
Feb 24, 2018
Walter Bright
Feb 24, 2018
Walter Bright
Feb 24, 2018
Walter Bright
Feb 24, 2018
Walter Bright
[Issue 16243] wrong C++ argument passing with empty struct when interfacing with Clang
Feb 24, 2018
Walter Bright
Feb 24, 2018
Walter Bright
Feb 28, 2018
Walter Bright
Sep 05, 2018
David Nadlinger
Sep 05, 2018
Iain Buclaw
July 06, 2016
https://issues.dlang.org/show_bug.cgi?id=16243

Martin Nowak <code@dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|wrong argument passed with  |wrong C++ argument passing
                   |empty struct and 6 integers |with empty struct and 6
                   |                            |integers

--- Comment #1 from Martin Nowak <code@dawg.eu> ---
Complete test case, also requires a C++ roundtrip. C++ compiler is.
----
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin12.2.0
Thread model: posix
----
cat > cpp.cc << CODE
struct S13956
{
};

void check13956(S13956 arg0, int arg1, int arg2, int arg3, int arg4, int arg5,
int arg6);

void func13956(S13956 arg0, int arg1, int arg2, int arg3, int arg4, int arg5,
int arg6)
{
    check13956(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
}
CODE

cat > bug.d << CODE
struct S13956
{
}

extern(C++) void func13956(S13956 arg0, int arg1, int arg2, int arg3, int arg4,
int arg5, int arg6)
{
    check13956(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
}

extern(C++) void check13956(S13956 arg0, int arg1, int arg2, int arg3, int
arg4, int arg5, int arg6)
{
    assert(arg0 == S13956());
    assert(arg1 == 1);
    assert(arg2 == 2);
    assert(arg3 == 3);
    assert(arg4 == 4);
    assert(arg5 == 5);
    assert(arg6 == 6); // fails on OSX 32-bit
}

void main()
{
    func13956(S13956(), 1, 2, 3, 4, 5, 6);
}
CODE

c++ -m32 -c cpp.cc
dmd -m32 cpp.o -run bug

--
July 07, 2016
https://issues.dlang.org/show_bug.cgi?id=16243

--- Comment #2 from Martin Nowak <code@dawg.eu> ---
Also fails with a single int argument.

cat > cpp.cc << CODE
#include <stdio.h>
struct S13956
{
};

void check13956(S13956 arg0, int arg1);

void func13956(S13956 arg0, int arg1)
{
    printf("C %d\n", arg1);
    check13956(arg0, arg1);
}
CODE

cat > bug.d << CODE
import core.stdc.stdio;
struct S13956
{
}

extern(C++) void func13956(S13956 arg0, int arg1)
{
    check13956(arg0, arg1);
}

extern(C++) void check13956(S13956 arg0, int arg1)
{
    printf("C %d\n", arg1);
    assert(arg0 == S13956());
    assert(arg1 == 1);
}

void main()
{
    func13956(S13956(), 1);
}
CODE

c++ -m32 -c cpp.cc
dmd -m32 cpp.o -run bug

--
July 24, 2016
https://issues.dlang.org/show_bug.cgi?id=16243

Martin Nowak <code@dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |regression

--- Comment #3 from Martin Nowak <code@dawg.eu> ---
Now this also fails on the OSX-64/32 test on the auto-tester, so this might actually be a relevant regression.

--
July 24, 2016
https://issues.dlang.org/show_bug.cgi?id=16243

kinke@gmx.net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kinke@gmx.net

--- Comment #4 from kinke@gmx.net ---
clang doesn't pass empty structs at all for 32-bit, while GCC does. We have such a special case in LDC too for 32-bit OSX, where we assume clang, but not for 32-bit Linux, where we assume GCC. See https://github.com/ldc-developers/ldc/blob/master/gen/abi-x86.cpp#L214.

--
July 27, 2016
https://issues.dlang.org/show_bug.cgi?id=16243

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #5 from Walter Bright <bugzilla@digitalmars.com> ---
So the regression is that Apple switched to clang, and clang does things differently?

--
July 27, 2016
https://issues.dlang.org/show_bug.cgi?id=16243

Jacob Carlborg <doob@me.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |doob@me.com

--- Comment #6 from Jacob Carlborg <doob@me.com> ---
(In reply to Walter Bright from comment #5)
> So the regression is that Apple switched to clang, and clang does things differently?

There's a long time since Apple switched to Clang. GCC is dead on Apple platforms. I've mentioned this several times that the autotester should switch to Clang.

--
September 12, 2016
https://issues.dlang.org/show_bug.cgi?id=16243

Martin Nowak <code@dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |braddr@puremagic.com

--- Comment #7 from Martin Nowak <code@dawg.eu> ---
(In reply to kinke from comment #4)
> clang doesn't pass empty structs at all for 32-bit, while GCC does. We have such a special case in LDC too for 32-bit OSX, where we assume clang, but not for 32-bit Linux, where we assume GCC. See https://github.com/ldc-developers/ldc/blob/master/gen/abi-x86.cpp#L214.

Thanks, assuming clang by default on OSX indeed seems like a reasonable
solution.
We also have that issue with GCC5's C++ ABI change
(http://developers.redhat.com/blog/2015/02/05/gcc5-and-the-c11-abi/), so
detecting the actual compiler might be helpful as well.

(In reply to Jacob Carlborg from comment #6)
> There's a long time since Apple switched to Clang. GCC is dead on Apple platforms. I've mentioned this several times that the autotester should switch to Clang.

Yes, would be good if we updated the auto-testers to use clang @Brad.

--
September 12, 2016
https://issues.dlang.org/show_bug.cgi?id=16243

--- Comment #8 from Jacob Carlborg <doob@me.com> ---
(In reply to Martin Nowak from comment #7)

> We also have that issue with GCC5's C++ ABI change (http://developers.redhat.com/blog/2015/02/05/gcc5-and-the-c11-abi/), so detecting the actual compiler might be helpful as well.

As far as I understand, it's configurable if that ABI should be used or not. So just detecting the compiler is not enough, unless we decide to only support one ABI.

--
September 12, 2016
https://issues.dlang.org/show_bug.cgi?id=16243

--- Comment #9 from Jacob Carlborg <doob@me.com> ---
(In reply to kinke from comment #4)
> clang doesn't pass empty structs at all for 32-bit, while GCC does. We have such a special case in LDC too for 32-bit OSX, where we assume clang, but not for 32-bit Linux, where we assume GCC. See https://github.com/ldc-developers/ldc/blob/master/gen/abi-x86.cpp#L214.

Clang claims to be compatible with GCC. If there's a case when it's not compatible, it might be a bug in Clang.

--
September 14, 2016
https://issues.dlang.org/show_bug.cgi?id=16243

--- Comment #10 from Joakim <dbugz@joakim.fea.st> ---
I ran into this on Android/ARM too, with ldc.  As the linked ldc comment and Jacob note, this is an incompatibility in the way clang and gcc work with empty structs on every platform, whether Linux/x86 or Android/ARM.  This test and the auto-tester simply use gcc on every other tested platform, while clang is the system compiler on OS X now.

--
« First   ‹ Prev
1 2 3