D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2382 - spec is not clear on what is allowed as global/static initializers
Summary: spec is not clear on what is allowed as global/static initializers
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 All
: P2 normal
Assignee: No Owner
URL:
Keywords: spec
Depends on:
Blocks:
 
Reported: 2008-10-01 18:48 UTC by Tomas Lindquist Olsen
Modified: 2014-02-15 13:12 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 Tomas Lindquist Olsen 2008-10-01 18:48:22 UTC
I can't find anywhere in the spec where it's clarified what can be used as a global/static initializer (only some special cases, like static struct initializers)

for example it's valid to initialize a global with the address of a function, statically. however, for example, it's not allowed to cast this function pointer to an integer even though there's no technical reason this should not be allowed.
Comment 1 Walter Bright 2012-01-22 14:43:45 UTC
Casting a pointer to an int may require halving its size, and the object file format often does not support that.