[Issue 874] New: Incorrect codegen (?) with tuples, string constants, and AAs
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jan 22 20:12:32 PST 2007
http://d.puremagic.com/issues/show_bug.cgi?id=874
Summary: Incorrect codegen (?) with tuples, string constants, and
AAs
Product: D
Version: 1.00
Platform: PC
OS/Version: Windows
Status: NEW
Keywords: wrong-code
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: jarrett.billingsley at gmail.com
I don't know how else to describe this.
template AA(V, K)
{
V[K] AA(T...)(T args)
{
V[K] ret;
K key;
foreach(i, arg; args)
{
static if(!(i & 1))
key = arg;
else
ret[key] = arg;
}
return ret;
}
}
void main()
{
char[][char[]] array = AA!(char[], char[])("a", "b", "c", "d");
writefln("length = ", array.length);
foreach(k, v; array)
writefln("array[", k, "] = ", v);
}
This code will give bizarre output when printing out the contents of the
returned AA. This usually is weird characters, and usually results in a
"4invalid UTF-8 sequence" exception. Stranger still, the output changes
depending on how many string literals there are in main(). This happens in
both -debug and -release modes, although they give different output.
--
More information about the Digitalmars-d-bugs
mailing list