Bug 2692 – alignment of double on x86 linux is incorrect
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2009-02-27T07:39:00Z
Last change time
2015-06-09T05:15:19Z
Keywords
wrong-code
Assigned to
bugzilla
Creator
tomas
Comments
Comment #0 by tomas — 2009-02-27T07:39:35Z
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;
}