I'm doing some meta stuff and came across a few problems.

First of is described here: http://d.puremagic.com/issues/show_bug.cgi?id=2454

Second one is slightly different and this time I am less sure whether it is a bug.
The following code is indetended to print offsets of all its members:

struct Test
{
    short s;
    int i;
    float f;
    double d;

    void test()
    {
        writefln("expected output:");
writefln( cast(char*)&s - cast(char*)this ); // writefln(s.offsetof); writefln( cast(char*)&i - cast(char*)this ); // writefln(i.offsetof); writefln( cast(char*)&f - cast(char*)this ); // writefln(f.offsetof); writefln( cast(char*)&d - cast(char*)this ); // writefln(d.offsetof);

        writefln("actual output:");
        foreach (m; this.tupleof) {
// writefln(m.offsetof); // Error: no property 'offsetof' for type 'short'
            writefln( cast(char*)&m - cast(char*)this);
        }
    }
}

expected output:
0
4
8
16

actual output:
-52
-48
-44
-40

Am I doing something wrong?

Reply via email to