Bug 4485 – CT only arrays appear in executable

Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
Other
OS
Windows
Creation time
2010-07-18T19:54:28Z
Last change time
2018-10-22T03:59:21Z
Assigned to
No Owner
Creator
strtr

Comments

Comment #0 by strtr — 2010-07-18T19:54:28Z
---- module main; const char[] CT_STRING = "int i=0;"; void main(){ mixin( CT_STRING ); } ---- The string can be found in the executable.
Comment #1 by Marco.Leise — 2014-01-18T17:36:58Z
That is correct. that other module "use_CT_STRING.d" could import it. Its removal can only be done by whole program optimizations and or the external linker. Have you tried actually declaring a compile time string like this?: enum CT_STRING = "int i = 0;";
Comment #2 by pro.mathias.lang — 2018-10-22T03:59:21Z
Indeed, this is the correct behavior. `static immutable` + initializer, or `static const` + initializer leads to a manifest constant which is an lvalue (you can take the address of it). On the other hand, `enum` leads to an rvalue (much like a define, it is copy pasted everywhere). Closing as INVALID.