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

--- Comment #0 from 2011-07-19 11:52:32 PDT ---
Create two files with these contents.

File: test.c

typedef struct
    float r,g,b,a;

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

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:
------- You are receiving this mail because: -------

Reply via email to