[Issue 6348] New: Returning a struct from a C library function doesn't work correctly in 64 bit binaries
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jul 19 11:57:52 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6348
Summary: Returning a struct from a C library function doesn't
work correctly in 64 bit binaries
Product: D
Version: D1 & D2
Platform: x86_64
OS/Version: Linux
Status: NEW
Severity: major
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: siegelords_abode at yahoo.com
--- Comment #0 from siegelords_abode at yahoo.com 2011-07-19 11:52:32 PDT ---
Create two files with these contents.
File: test.c
typedef struct
{
float r,g,b,a;
} COLOR;
COLOR makecol(float r, float g, float b, float a)
{
COLOR ret;
ret.r = r;
ret.g = g;
ret.b = b;
ret.a = a;
return ret;
}
File: test.d
import std.stdio;
struct COLOR
{
float r,g,b,a;
}
extern (C) COLOR makecol(float r, float g, float b, float a);
void main()
{
auto col = makecol(1, 0.5, 1, 0.5);
writefln("%s, %s, %s, %s", col.r, col.g, col.b, col.a);
}
Now compile the whole mess and test:
gcc -c test.c && ar -r test.a test.o
dmd test.d test.a
./test
The expected output is "1, 0.5, 1, 0.5" but actually it output something
completely different ("0, 0, 0, 0" on my system). This happens with both dmd
2.054 and 1.069.
Perhaps this bug is related to 5570?
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list