[Issue 1314] Dupping an empty array creates a null array
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jul 5 16:32:54 PDT 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1314
------- Comment #4 from leikeze at gmail.com 2007-07-05 18:32 -------
(In reply to comment #0)
> Dupping an empty array creates a null array:
> ---- ----
> import std.stdio;
>
> void main(char[][] args) {
> writefln("" is null); // false
> writefln("".dup is null); // true
> writefln("".idup is null); // true
> writefln("".dup.ptr); // 0000
> }
>
According to http://www.digitalmars.com/d/arrays.html shouldn't "".length be 1?
> String literals already have a 0 appended to them, so can be used directly
So shouldn't "".dup return a char array of length 1, containing the null
character? Or is "" a special case that is interpreted as null?
--
More information about the Digitalmars-d-bugs
mailing list