digitalmars.D.bugs - [Issue 2173] New: foreach iteration not possible for associative array indexed with static array
- d-bugmail puremagic.com (29/29) Jun 25 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2173
- d-bugmail puremagic.com (17/17) Jun 25 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2173
- Jarrett Billingsley (5/18) Jun 26 2008 Now static arrays are the only type that can be out, ref, or lazy. I do...
- Koroskin Denis (3/23) Jun 27 2008 That's not hard to patch je to jne, I assume :)
- d-bugmail puremagic.com (14/14) Jul 02 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2173
- d-bugmail puremagic.com (12/12) Feb 18 2010 http://d.puremagic.com/issues/show_bug.cgi?id=2173
http://d.puremagic.com/issues/show_bug.cgi?id=2173 Summary: foreach iteration not possible for associative array indexed with static array Product: D Version: 1.031 Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P3 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: georg op-co.de Trying to foreach through an AA[SA] generates a compiler error: import std.stdio; import std.md5; int main(char[][] args) { int[ubyte[16]] md5count; foreach (md5, count; md5count) writefln("%s: %d", std.md5.digestToString(md5), count); return 0; } Both gdc and dmd bail out on the foreach statement with: "test.d(5): Error: cannot have out or ref parameter of type ubyte[16u]" Possible workarounds: * use a wrapper struct for the static array (looks ugly) * use foreach (md5; md5count.keys) ... count = md5count[md5] (decreases performance almost by 50%) --
Jun 25 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2173 davidl 126.com changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch i bet the code actually meant as following: mtype.c (2790): if (arg->storageClass & (STCout | STCref | STClazy)) { --- if (t->ty == Tsarray) +++ if (t->ty != Tsarray) error(loc, "cannot have out or ref parameter of type %s", t->toChars()); } I hand-crafted a dmd which bypass this check, it can generate correct binary. --
Jun 25 2008
<d-bugmail puremagic.com> wrote in message news:g3vdj3$114l$1 digitalmars.com...http://d.puremagic.com/issues/show_bug.cgi?id=2173i bet the code actually meant as following: mtype.c (2790): if (arg->storageClass & (STCout | STCref | STClazy)) { --- if (t->ty == Tsarray) +++ if (t->ty != Tsarray) error(loc, "cannot have out or ref parameter of type %s", t->toChars()); }Now static arrays are the only type that can be out, ref, or lazy. I don't think that's much of a fix. Maybe just get rid of the check entirely.I hand-crafted a dmd which bypass this check, it can generate correct binary.How can you do that? The backend is closed source.
Jun 26 2008
On Thu, 26 Jun 2008 17:19:41 +0400, Jarrett Billingsley <kb3ctd2 yahoo.com> wrote:<d-bugmail puremagic.com> wrote in message news:g3vdj3$114l$1 digitalmars.com...That's not hard to patch je to jne, I assume :)http://d.puremagic.com/issues/show_bug.cgi?id=2173i bet the code actually meant as following: mtype.c (2790): if (arg->storageClass & (STCout | STCref | STClazy)) { --- if (t->ty == Tsarray) +++ if (t->ty != Tsarray) error(loc, "cannot have out or ref parameter of type %s", t->toChars()); }Now static arrays are the only type that can be out, ref, or lazy. I don't think that's much of a fix. Maybe just get rid of the check entirely.I hand-crafted a dmd which bypass this check, it can generate correct binary.How can you do that? The backend is closed source.
Jun 27 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2173 umm, the patch is incorrect.. bypassing the whole test should work. /* if (arg->storageClass & (STCout | STCref | STClazy)) { if (t->ty == Tsarray) if (t->ty != Tsarray) error(loc, "cannot have out or ref parameter of type %s", t->toChars()); } */ --
Jul 02 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2173 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bearophile_hugs eml.cc Resolution| |WORKSFORME I think this bug is now fixed, because fixed-sized arrays are managed by value. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 18 2010