www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2692] New: alignment of double on x86 linux is incorrect

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2692

           Summary: alignment of double on x86 linux is incorrect
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: wrong-code
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: tomas famolsen.dk


See this testcase, DMD fails the second assertion, so it does not match the
companion C compiler (which is gcc on linux) as per spec.

The correct alignment of double is 4.

D CODE:
=======

void main()
{
    Foo f = foo();
    assert(f.i == 42);
    assert(f.d == 2.5);
}

extern(C):
struct Foo
{
    int i;
    double d;
}
Foo foo();


C CODE:
=======

typedef struct
{
    int i;
    double d;
} S;

S foo(void)
{
    S s;
    s.i = 42;
    s.d = 2.5;
    return s;
}


-- 
Feb 27 2009
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2692


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #1 from bugzilla digitalmars.com  2009-04-01 13:47 -------
Fixed DMD 1.042 and 2.027


-- 
Apr 01 2009