D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6710 - Can't use .sizeof in pragma(msg) call
Summary: Can't use .sizeof in pragma(msg) call
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks: 340
  Show dependency treegraph
 
Reported: 2011-09-21 20:50 UTC by Andrej Mitrovic
Modified: 2012-04-19 18:48 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Andrej Mitrovic 2011-09-21 20:50:04 UTC
struct Foo
{
    static assert(Foo.sizeof == 4);  // ok
    pragma(msg, Foo.sizeof);  // Error: struct test.Foo no size yet for forward reference
    
    int x;
}

void main() { }

I'm not sure if it's genuinely a bug, IOW maybe the pragma is evaluated before the compiler does a pass to see which fields the struct is holding?
Comment 1 Andrej Mitrovic 2012-01-04 06:56:49 UTC
Workaround: Put the pragma call outside of the structure definition.
Comment 2 Andrej Mitrovic 2012-04-19 18:48:26 UTC
Fixed in 2.059, don't know by which commit though.