D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4485 - CT only arrays appear in executable
Summary: CT only arrays appear in executable
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: Other Windows
: P2 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-18 19:54 UTC by strtr
Modified: 2018-10-22 03:59 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 strtr 2010-07-18 19:54:28 UTC
----
module main;

const char[] CT_STRING = "int i=0;";

void main(){
	mixin( CT_STRING );
}
----
The string can be found in the executable.
Comment 1 Marco Leise 2014-01-18 17:36:58 UTC
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 Mathias LANG 2018-10-22 03:59:21 UTC
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.