digitalmars.D.bugs - [Issue 800] New: writefln() on an associative array fails hard
- d-bugmail puremagic.com (22/22) Jan 06 2007 http://d.puremagic.com/issues/show_bug.cgi?id=800
- d-bugmail puremagic.com (8/8) Jan 06 2007 http://d.puremagic.com/issues/show_bug.cgi?id=800
- d-bugmail puremagic.com (9/9) Jan 07 2007 http://d.puremagic.com/issues/show_bug.cgi?id=800
- d-bugmail puremagic.com (12/12) Jan 07 2007 http://d.puremagic.com/issues/show_bug.cgi?id=800
- d-bugmail puremagic.com (4/4) Feb 02 2007 http://d.puremagic.com/issues/show_bug.cgi?id=800
- d-bugmail puremagic.com (6/6) Feb 10 2007 http://d.puremagic.com/issues/show_bug.cgi?id=800
- d-bugmail puremagic.com (21/21) Feb 10 2007 http://d.puremagic.com/issues/show_bug.cgi?id=800
http://d.puremagic.com/issues/show_bug.cgi?id=800 Summary: writefln() on an associative array fails hard Product: D Version: 1.00 Platform: PC OS/Version: Windows Status: NEW Severity: critical Priority: P2 Component: Phobos AssignedTo: bugzilla digitalmars.com ReportedBy: deewiant gmail.com import std.stdio; void main() { int[int] foo; foo[1] = 2; writefln("%s", foo); } This outputs "[", some seemingly-random numbers including hundreds of zeroes, and dies in an Access Violation. It looks like it's reading memory in the completely wrong place, possibly treating the AA as a dynamic array. --
Jan 06 2007
http://d.puremagic.com/issues/show_bug.cgi?id=800 ------- Comment #1 from lio lunesu.com 2007-01-07 01:09 ------- Apparently, the type-info of an AA changed. std/format.d uses the character at index [9] to identify the type, and it used to be 'H' (HashTable?), but now it's 'A', same as normal arrays: int[] => TypeInfo_Ai int[int] => TypeInfo_AssociativeArray --
Jan 06 2007
http://d.puremagic.com/issues/show_bug.cgi?id=800 ------- Comment #2 from lio lunesu.com 2007-01-07 02:00 ------- Created an attachment (id=90) --> (http://d.puremagic.com/issues/attachment.cgi?id=90&action=view) Patch for std.format to dump contents of Associative Arrays This patch adds putAArray to std.format.doFormat. It prints the contents of an AA similar to python: {key:value,key2:value2} (D had no literal AA syntax, so I didn't know what to pick instead) --
Jan 07 2007
http://d.puremagic.com/issues/show_bug.cgi?id=800 lio lunesu.com changed: What |Removed |Added ---------------------------------------------------------------------------- BugsThisDependsOn| |761 Keywords| |patch ------- Comment #3 from lio lunesu.com 2007-01-07 02:05 ------- Important: if the doFormat patch from issue 652 or 761 is applied, putAArray should also call doFormat with the 'parse' parameter set to false! This prevents any "%" in either key or value strings from being interpreted (resulting in the bug from issue 761) --
Jan 07 2007
http://d.puremagic.com/issues/show_bug.cgi?id=800 ------- Comment #4 from bugzilla digitalmars.com 2007-02-03 00:51 ------- *** Bug 801 has been marked as a duplicate of this bug. *** --
Feb 02 2007
http://d.puremagic.com/issues/show_bug.cgi?id=800 ------- Comment #5 from dvdfrdmn users.sf.net 2007-02-10 11:41 ------- Created an attachment (id=100) --> (http://d.puremagic.com/issues/attachment.cgi?id=100&action=view) Patch to align the address of the value --
Feb 10 2007
http://d.puremagic.com/issues/show_bug.cgi?id=800 dvdfrdmn users.sf.net changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dvdfrdmn users.sf.net ------- Comment #6 from dvdfrdmn users.sf.net 2007-02-10 11:42 ------- The patch in #2 does not take alignment of the value into account. The following prints "[a:50331648]" ---- import std.format; import std.string; void main() { int[char] m; m['a'] = 3; assert(find(format("%s",m), "a:3") != -1); } ---- Attached an example patch that fixes the problem, but I don't think copying from aaA.d is a good idea. --
Feb 10 2007