www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Scoping bug with offsetof?

reply brad beveridge <brad nowhere.com> writes:
I think I may have found a bug - well it is certainly something :)
The following code causes an error with DMD 0.121 on Linux
The error is
"error.d(12): this for a needs to be type Foo not type Bar *"

This is a regression, the DMD 0.112 (I think?) allowed this code.

Thanks
Brad

<code>
import std.stdio;

struct Foo
{
     float a;
}

struct Bar
{
     void test()
     {
         writefln(Foo.a.offsetof);  // comment this line in/out
     }
}

int main(char[][] arg)
{
     writefln(Foo.a.offsetof);
     return 0;
}
</code>
Apr 25 2005
parent reply Brad Beveridge <brad somewhere.net> writes:
brad beveridge wrote:
 I think I may have found a bug - well it is certainly something :)
 The following code causes an error with DMD 0.121 on Linux
 The error is
 "error.d(12): this for a needs to be type Foo not type Bar *"
 
 This is a regression, the DMD 0.112 (I think?) allowed this code.
 
 Thanks
 Brad
 
 <code>
 import std.stdio;
 
 struct Foo
 {
     float a;
 }
 
 struct Bar
 {
     void test()
     {
         writefln(Foo.a.offsetof);  // comment this line in/out
     }
 }
 
 int main(char[][] arg)
 {
     writefln(Foo.a.offsetof);
     return 0;
 }
 </code>
Note - this bug also happens with Foo.a.sizeof Brad
Apr 25 2005
parent Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Brad Beveridge schrieb am Tue, 26 Apr 2005 11:48:15 +1200:
 brad beveridge wrote:
 I think I may have found a bug - well it is certainly something :)
 The following code causes an error with DMD 0.121 on Linux
 The error is
 "error.d(12): this for a needs to be type Foo not type Bar *"
 
 This is a regression, the DMD 0.112 (I think?) allowed this code.
 
 Thanks
 Brad
 
 <code>
 import std.stdio;
 
 struct Foo
 {
     float a;
 }
 
 struct Bar
 {
     void test()
     {
         writefln(Foo.a.offsetof);  // comment this line in/out
     }
 }
 
 int main(char[][] arg)
 {
     writefln(Foo.a.offsetof);
     return 0;
 }
 </code>
Note - this bug also happens with Foo.a.sizeof
Added to DStress as http://dstress.kuehne.cn/run/offsetof_78.d http://dstress.kuehne.cn/run/offsetof_79.d http://dstress.kuehne.cn/run/offsetof_80.d http://dstress.kuehne.cn/run/sizeof_13.d http://dstress.kuehne.cn/run/sizeof_14.d http://dstress.kuehne.cn/run/sizeof_15.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCbivs3w+/yD4P9tIRAgMdAJ0TyLMP20aZsCDMlAkSmtT54EDIBACfUJHW wElkecIAH8H6Adv2cfCkO48= =6vFZ -----END PGP SIGNATURE-----
Apr 26 2005