Thread overview |
---|
July 05, 2007 [Issue 1314] New: Dupping an empty array creates a null array | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=1314 Summary: Dupping an empty array creates a null array Product: D Version: 2.002 Platform: PC OS/Version: Windows Status: NEW Keywords: wrong-code Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: brunodomedeiros+bugz@gmail.com 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 } -- |
July 05, 2007 [Issue 1314] Dupping an empty array creates a null array | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1314 ------- Comment #1 from bugzilla@digitalmars.com 2007-07-05 13:31 ------- Why is this a problem? -- |
July 05, 2007 [Issue 1314] Dupping an empty array creates a null array | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1314 ------- Comment #2 from brunodomedeiros+bugz@gmail.com 2007-07-05 17:56 ------- I tought you had changed D some releases ago, such that empty arrays became different than null arrays, wasn't that the case? (if not this is not a bug) -- |
July 05, 2007 Re: [Issue 1314] Dupping an empty array creates a null array | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | d-bugmail@puremagic.com wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=1314
>
> ------- Comment #2 from brunodomedeiros+bugz@gmail.com 2007-07-05 17:56 -------
> I tought you had changed D some releases ago, such that empty arrays became
> different than null arrays, wasn't that the case? (if not this is not a bug)
He only changed it so that setting .length to 0 no longer sets .ptr to null. He didn't change anything else regarding empty arrays AFAIK.
|
July 05, 2007 [Issue 1314] Dupping an empty array creates a null array | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1314 ------- Comment #4 from leikeze@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? -- |
July 05, 2007 [Issue 1314] Dupping an empty array creates a null array | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1314 ------- Comment #5 from chris@dprogramming.com 2007-07-05 18:57 ------- Similar to why an empty struct should still allocate a byte. -- |
July 06, 2007 [Issue 1314] Dupping an empty array creates a null array | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1314 brunodomedeiros+bugz@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID ------- Comment #6 from brunodomedeiros+bugz@gmail.com 2007-07-06 04:03 ------- (In reply to comment #3) > d-bugmail@puremagic.com wrote: > > http://d.puremagic.com/issues/show_bug.cgi?id=1314 > > > > ------- Comment #2 from brunodomedeiros+bugz@gmail.com 2007-07-05 17:56 ------- > > I tought you had changed D some releases ago, such that empty arrays became different than null arrays, wasn't that the case? (if not this is not a bug) > He only changed it so that setting .length to 0 no longer sets .ptr to null. He didn't change anything else regarding empty arrays AFAIK. You're right, I misunderstood bug #429 . (and "".length should be 0, there is no doubt about that) -- |
Copyright © 1999-2021 by the D Language Foundation