Bug 1465 – Value of x.stringof changes when used as a template parameter

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2007-09-01T03:39:00Z
Last change time
2015-06-09T01:14:15Z
Assigned to
bugzilla
Creator
reiner.pope

Comments

Comment #0 by reiner.pope — 2007-09-01T03:39:57Z
The following code, when compiling, prints "x" then "int". It should print "x" both times. template Print(string B) { pragma(msg, B); } int x; pragma(msg, x.stringof); alias Print!(x.stringof) s; Assigning x.stringof to a compile-time constant string fixes it, eg const text = x.stringof; pragma(msg, text); // prints x alias Print!(x.stringof) p; // prints x
Comment #1 by matti.niemenmaa+dbugzilla — 2007-09-01T03:49:01Z
*** This bug has been marked as a duplicate of 1168 ***