DMD problem: incorrect struct.sizeof
Jascha Wetzel
"[firstname]" at mainia.de
Thu Jan 25 12:28:08 PST 2007
Something's weird if you put a ubyte, byte oder char at the end of a
struct. The program below prints
str1.sizeof: 4
str2.sizeof: 8
str3.sizeof: 12
Reproducable with DMD 1.0, 1.001 and 1.002 on win32 - I didn't check
older versions.
import std.stdio;
struct str1 {
ushort a;
ubyte b;
}
struct str2 {
uint a;
ubyte b;
}
struct str3 {
ushort a;
uint c;
ubyte b;
}
void main()
{
writefln("str1.sizeof: %d", str1.sizeof);
writefln("str2.sizeof: %d", str2.sizeof);
writefln("str3.sizeof: %d", str3.sizeof);
}
More information about the Digitalmars-d
mailing list