D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1684 - offsetof does not work, adding cast is workaround
Summary: offsetof does not work, adding cast is workaround
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Linux
: P2 normal
Assignee: No Owner
URL:
Keywords: patch, rejects-valid
Depends on:
Blocks:
 
Reported: 2007-11-22 03:02 UTC by Frank Benoit
Modified: 2015-06-09 05:11 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Frank Benoit 2007-11-22 03:02:55 UTC
Sometime .offsetof does not compile.
Adding a cast can make it compile

template Test( uint memberOffset ){}

class MyClass {
    int flags2;
    mixin Test!(cast(uint)flags2.offsetof) t1; // compiles ok
    mixin Test!(cast(int)flags2.offsetof)  t2; // compiles ok
    mixin Test!(flags2.offsetof)           t3; // Error: no property 'offsetof' for type 'int'
}
Comment 2 Kenji Hara 2011-07-14 04:34:51 UTC
This problem occurs also in D2.