Bug with offsetof?

Geancarlo geancarlo.rocha+d at gmail.com
Sun Nov 25 19:23:35 PST 2012


Hello, I'm using DMD32 D Compiler v2.060 for on Windows.


module main;

import std.stdio;

int main(string[] argv)
{
	writeln(TestStruct.x.offsetof);
	TestClass.test1();
	TestClass var = new TestClass();
	var.test2();
	return 0;
}

class TestClass
{
	static void test1()
	{
		writeln(TestStruct.x.offsetof);
	}

	void test2()
	{
		writeln(TestStruct.x.offsetof);//bug here
	}
}

struct TestStruct
{
	int x;
}

While test1 gives me no issues, test2 causes the following error:

Error: this for x needs to be type TestStruct not type 
main.TestClass		


Is this a known bug? How can I work around this issue in order to 
use offsetof from a class function that is not static?

Thanks


More information about the Digitalmars-d-learn mailing list