Thread overview | ||||||
---|---|---|---|---|---|---|
|
October 31, 2005 offsetof: Bug or Documentation Error? | ||||
---|---|---|---|---|
| ||||
I found an inconsistency in the D Documentation. In class.html, under the heading "Field Properties" there is an example: class Foo { int x; } ... void test(Foo foo) { size_t o; o = Foo.x.offsetof; // yields 8 o = foo.x.offsetof; // error, .offsetof an int type }My own test code contradicts this, note that the error condition is opposite the example:class Foo { int x;}int main() { Foo foo = new Foo; size_t o; o = Foo.x.offsetof; // error: 'this' is only allowed in non-static // member functions // error: this for x needs to be type Foo not // type int o = foo.x.offsetof; // yields 8} |
November 01, 2005 Re: offsetof: Bug or Documentation Error? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Garett Bass | Garett Bass wrote: > I found an inconsistency in the D Documentation. In class.html, under the heading "Field Properties" there is an example: > > class Foo > { > int x; > } > .... > void test(Foo foo) > { > size_t o; > > o = Foo.x.offsetof; // yields 8 > o = foo.x.offsetof; // error, .offsetof an int type > }My own test code contradicts this, note that the error condition is opposite the example:class Foo { int x;}int main() { Foo foo = new Foo; size_t o; o = Foo.x.offsetof; // error: 'this' is only allowed in non-static // member functions // error: this for x needs to be type Foo not // type int o = foo.x.offsetof; // yields 8} > > Starting to seem like a bug to me. The following code: class Foo { int x; } int main(char[][] args) { Foo foo = new Foo(); foo.x.offsetof; } gives a runtime assert error after main: Error: AssertError Failure test.d(11) -- Bruno Medeiros - CS/E student "Certain aspects of D are a pathway to many abilities some consider to be... unnatural." |
November 01, 2005 Re: offsetof: Bug or Documentation Error? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bruno Medeiros | In article <dk7eo0$2qji$1@digitaldaemon.com>, Bruno Medeiros says... > >Starting to seem like a bug to me. The following code: > > class Foo > { > int x; > } > > int main(char[][] args) > { > Foo foo = new Foo(); > foo.x.offsetof; > } > >gives a runtime assert error after main: > Error: AssertError Failure test.d(11) Thats your main() not returning... A better error message would be appreciated. /Oskar |
November 01, 2005 Re: offsetof: Bug or Documentation Error? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Oskar Linde | Oskar Linde wrote: > In article <dk7eo0$2qji$1@digitaldaemon.com>, Bruno Medeiros says... > >>Starting to seem like a bug to me. The following code: >> >> class Foo >> { >> int x; >> } >> >> int main(char[][] args) >> { >> Foo foo = new Foo(); >> foo.x.offsetof; >> } >> >>gives a runtime assert error after main: >> Error: AssertError Failure test.d(11) > > > Thats your main() not returning... A better error message would be appreciated. > > /Oskar > > Whoops, my bad :( . I've been using the same test source file all this time (which incindently has a return from main) that I never noticed that. -- Bruno Medeiros - CS/E student "Certain aspects of D are a pathway to many abilities some consider to be... unnatural." |
Copyright © 1999-2021 by the D Language Foundation