[Issue 1884] New: manifest constants for strings
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Feb 29 18:39:23 PST 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1884
Summary: manifest constants for strings
Product: D
Version: 2.011
Platform: PC
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: ddparnell at bigpond.com
The code below does not work as I expected it to.
//-----------------
import std.stdio;
void main()
{
enum string foo = "qwerty";
std.stdio.writefln("'%s'", foo);
foreach(int i, char c; foo)
writefln("[%s]%s", i, cast(int)c);
enum fob = "qwerty";
std.stdio.writefln("'%s'", fob);
foreach(int i, char c; fob)
writefln("[%s]%s", i, cast(int)c);
const bar = "qwerty";
std.stdio.writefln("'%s'", bar);
foreach(int i, char c; bar)
writefln("[%s]%s", i, cast(int)c);
}
//-----------------
I was expecting three identical strings to printout plus each character to be
correct. Instead I got this ...
'qwerty'
[0]176
[1]236
[2]65
' ÿý'
[0]0
[1]0
[2]0
[3]0
[4]152
[5]236
'qwerty'
[0]113
[1]119
[2]101
[3]114
[4]116
[5]121
Which seems to me that only the form "const x " works.
--
More information about the Digitalmars-d-bugs
mailing list