Bug 1591 – 2.006 breaks writef("%s", str) where str is a string
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2007-10-17T20:25:00Z
Last change time
2015-06-09T01:14:19Z
Assigned to
andrei
Creator
jemandy
Comments
Comment #0 by jemandy — 2007-10-17T20:25:30Z
2.006 breaks the following program:
import std.stdio;
void main()
{
// char[] str = cast(char[])("hello, world");
string str = cast(string)("hello, world");
writefln("%s", str); // Breaks in 2.006
}
This does not compile with either definition of str, the definition out version or the active definition. (Note, the cast is needed for the char[] definition of str, but not the string definition of str).
Comment #1 by ddparnell — 2007-10-17T20:45:35Z
This does NOT fail for me when using dmd 2.006 (Windows XP)
----
c:\temp>type test.d
import std.stdio;
void main()
{
string str = "hello, world";
writefln("%s", str);
}
c:\temp>dmd test.d
y:\dmd\bin\..\..\dm\bin\link.exe test,,,user32+kernel32/noi;
c:\temp>test
hello, world
c:\temp>dmd
Digital Mars D Compiler v2.006
Copyright (c) 1999-2007 by Digital Mars written by Walter Bright
----
Comment #2 by jemandy — 2007-10-17T22:31:14Z
Oops, I had warnings enabled. (I compile from a batch file and had forgotten that I did this. I should have read the error message more carefully.) Try again with dmd -w test.d.
Comment #3 by ddparnell — 2007-10-17T22:43:14Z
Ok, now it fails. You could have inserted the error message into your original report to speed up problem determination.
----
c:\temp>dmd -w test
warning - y:\dmd\bin\..\src\phobos\std\format.d(2019): Error: statement is not reachable
y:\dmd\bin\..\src\phobos\std\format.d(2087): template instance std.format.getNthInt!(invariant(char)[],char) error instantiating
----
(P.S. I've had to turn off -w because of problems with std.stream).
Comment #4 by andrei — 2007-10-19T12:55:15Z
Fixed; the fix will go into the next minor release, when the bug will be closed. Thanks!