Bug 4109 – writeln doesn't work with empty static array
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2010-04-21T13:48:00Z
Last change time
2015-06-09T05:13:45Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2010-04-21T13:48:33Z
This D2 code:
import std.stdio: writeln;
void main() {
int[0] a;
writeln(a);
}
dmd 2.043 shows:
[...]\dmd\src\phobos\std\format.d(2040): Error: array index 0 is out of bounds obj[0 .. 0]
[...]\dmd\src\phobos\std\format.d(2040): Error: array index 0 is out of bounds [0..0]
Comment #1 by rsinfu — 2010-05-23T05:00:48Z
Fixed in svn r1546.
Comment #2 by bearophile_hugs — 2010-06-14T04:39:14Z
Reopened. Phobos needs to be debugged with warnings on. If I compile that program with:
dmd -w test.d
DMD 2.047 prints:
...\src\phobos\std\format.d(2040): Warning: statement is not reachable
...\src\phobos\std\format.d(2041): Warning: statement is not reachable