Struct members align in DMD 2.060
novice2
sorry at noem.ail
Sat Oct 6 20:25:51 PDT 2012
Some of my code broken in DMD 2.060.
I need packed struct without align to process data.
Is this bug or something changed in 2.060 ?
Code http://dpaste.dzfl.pl/212ca53b :
import std.stdio;
align(1) struct S1
{
char[2] c; //+0
uint u; //+2
}
struct S2
{
align(1):
char[2] c; //+0
uint u; //+2
}
struct S3
{
align(1) char[2] c; //+0
align(1) uint u; //+2
}
void main()
{
writeln("**** compiler ",__VENDOR__, " ", __VERSION__);
writeln;
writeln("S1.c.offsetof (should be 0) = ", S1.c.offsetof);
writeln("S1.u.offsetof (should be 2) = ", S1.u.offsetof);
writeln("S1.sizeof (should be 6) = ", S1.sizeof);
writeln;
writeln("S2.c.offsetof (should be 0) = ", S2.c.offsetof);
writeln("S2.u.offsetof (should be 2) = ", S2.u.offsetof);
writeln("S2.sizeof (should be 6) = ", S2.sizeof);
writeln;
writeln("S3.c.offsetof (should be 0) = ", S3.c.offsetof);
writeln("S3.u.offsetof (should be 2) = ", S3.u.offsetof);
writeln("S3.sizeof (should be 6) = ", S3.sizeof);
writeln;
}
Output:
**** compiler Digital Mars D 2059
S1.c.offsetof (should be 0) = 0
S1.u.offsetof (should be 2) = 2
S1.sizeof (should be 6) = 6
S2.c.offsetof (should be 0) = 0
S2.u.offsetof (should be 2) = 2
S2.sizeof (should be 6) = 6
S3.c.offsetof (should be 0) = 0
S3.u.offsetof (should be 2) = 2
S3.sizeof (should be 6) = 6
**** compiler Digital Mars D 2060
S1.c.offsetof (should be 0) = 0
S1.u.offsetof (should be 2) = 4
S1.sizeof (should be 6) = 8
S2.c.offsetof (should be 0) = 0
S2.u.offsetof (should be 2) = 2
S2.sizeof (should be 6) = 8
S3.c.offsetof (should be 0) = 0
S3.u.offsetof (should be 2) = 2
S3.sizeof (should be 6) = 8
More information about the Digitalmars-d-learn
mailing list