Bug 899 – structure field .offsetof property inaccessible in the scope
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2007-01-28T10:10:00Z
Last change time
2014-01-22T08:16:09Z
Keywords
industry, rejects-valid
Assigned to
nobody
Creator
dlang-bugzilla
Comments
Comment #0 by dlang-bugzilla — 2007-01-28T10:10:35Z
import std.stdio;
struct Test
{
int field;
}
void main()
{
writefln(Test.field.offsetof); // works
}
class Class
{
this()
{
writefln(Test.field.offsetof);
// Error: this for field needs to be type Test not type bug2.Class
// class bug2.Class member field is not accessible
}
}
Comment #1 by dlang-bugzilla — 2009-05-27T05:22:20Z
*** Issue 2302 has been marked as a duplicate of this issue. ***
Comment #2 by andrea.9940 — 2013-11-27T09:01:12Z
Tested on DMD 2.064
import std.stdio;
struct Test {
int field;
}
void main() {
writeln(Test.field.offsetof); // works
}
class Class {
void a() {
writeln(Test.field.offsetof);
// Error: this for field needs to be type Test not type main.Class
}
}
struct Struct {
void a() {
writeln(Test.field.offsetof);
// Error: this for field needs to be type Test not type Struct
}
}
Comment #3 by k.hara.pg — 2014-01-22T08:16:09Z
(In reply to comment #2)
> Tested on DMD 2.064
>
> import std.stdio;
> struct Test {
> int field;
> }
> void main() {
> writeln(Test.field.offsetof); // works
> }
> class Class {
> void a() {
> writeln(Test.field.offsetof);
> // Error: this for field needs to be type Test not type main.Class
> }
> }
> struct Struct {
> void a() {
> writeln(Test.field.offsetof);
> // Error: this for field needs to be type Test not type Struct
> }
> }
Finally fixed in 2.065a (git-head), by the compiler change:
https://github.com/D-Programming-Language/dmd/pull/2897