digitalmars.D.bugs - [Issue 1884] New: manifest constants for strings
- d-bugmail puremagic.com (53/53) Feb 29 2008 http://d.puremagic.com/issues/show_bug.cgi?id=1884
- d-bugmail puremagic.com (25/25) Feb 29 2008 http://d.puremagic.com/issues/show_bug.cgi?id=1884
- d-bugmail puremagic.com (9/9) Feb 29 2008 http://d.puremagic.com/issues/show_bug.cgi?id=1884
- d-bugmail puremagic.com (4/4) Mar 06 2008 http://d.puremagic.com/issues/show_bug.cgi?id=1884
- d-bugmail puremagic.com (22/22) Mar 26 2008 http://d.puremagic.com/issues/show_bug.cgi?id=1884
- d-bugmail puremagic.com (4/4) Mar 26 2008 http://d.puremagic.com/issues/show_bug.cgi?id=1884
- d-bugmail puremagic.com (11/11) Apr 17 2009 http://d.puremagic.com/issues/show_bug.cgi?id=1884
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 digitalmars.com
ReportedBy: ddparnell 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.
--
Feb 29 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1884
And if you think that was stringe, try this example ...
//-------------
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);
std.stdio.writefln("'%s'", "qwerty");
foreach(int i, char c; "qwerty")
writefln("[%s]%s", i, cast(int)c);
}
//---------
--
Feb 29 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1884
torhu yahoo.com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |torhu yahoo.com
Looks like it's related to 1794.
http://d.puremagic.com/issues/show_bug.cgi?id=1794
--
Feb 29 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1884 Fixed dmd 2.012 --
Mar 06 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1884
sardonicpresence gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |sardonicpresence gmail.com
What I assume is the same issue still occurs within structs as of 2.012 e.g.
//-----------------
import std.stdio;
struct Test
{
public string Text;
}
enum Test test = { Text: "test" };
void main()
{
std.stdio.writefln(test);
}
//-----------------
This results in the following output:
' âA ÓâA `äA ►ëA └ëA øA á£A ►×A ǃA ñA ñA ªA '
--
Mar 26 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1884
Sorry that should have been "std.stdio.writefln("'%s'", test.Text);".
--
Mar 26 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1884
clugdbug yahoo.com.au changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Neil's bug is actually totally different, and not related to strings in any
The original bug is fixed.
--
Apr 17 2009









d-bugmail puremagic.com 