I tried this with:
FreeBSD 11.0-RELEASE-p1
FreeBSD clang version 3.8.0 (tags/RELEASE_380/final 262564) (based on LLVM 3.8.0)
Target: x86_64-unknown-freebsd11.0
Thread model: posix
InstalledDir: /usr/bin
g++ (FreeBSD Ports Collection) 4.9.4
and it works, both with g++ and c++ (clang).
So it's a bit of a mystery at the moment.
Comment #2 by bugzilla — 2017-10-18T06:09:17Z
It does fail with -m32
Comment #3 by bugzilla — 2017-10-18T07:05:06Z
The problem turns out to be the C++ compiler returns:
struct S { float a = 1; }
in ST0:
_Z15passthrough_ptrP1S:
mov EAX,4[ESP]
fld float ptr [EAX]
ret
while DMD expects it to be returned in EAX:
_Z15passthrough_ptrP1S:
mov EAX,4[ESP]
fld float ptr [EAX]
ret
push EBP
mov EBP,ESP
sub ESP,018h
mov -010h[EBP],ESI
lea ECX,-4[EBP]
mov -0Ch[EBP],EDI
mov -4[EBP],EAX
mov -018h[EBP],ECX
call _Z15passthrough_ptrP1S@PC32
lea ESI,-8[EBP]
lea EDI,-4[EBP]
mov -8[EBP],EAX <== return value
mov ECX,4
xor EAX,EAX
rep
cmpsb
je L41
mov dword ptr -014h[EBP],0Fh
mov dword ptr -018h[EBP],offset FLAT:_TMP1[038h]@SYM32
call _d_assertp@PC32
L41: mov ESI,-010h[EBP]
mov EDI,-0Ch[EBP]
mov ESP,EBP
pop EBP
ret