https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96152
Bug ID: 96152
Summary: d: associative array literals don't have alignment
holes filled.
Product: gcc
Version: 10.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: d
Assignee: ibuclaw at gdcproject dot org
Reporter: ibuclaw at gdcproject dot org
Target Milestone: ---
auto assocArray(Keys, Values)(Keys keys, Values values)
{
void* aa;
{
if (values.length > keys.length)
values = values[0 .. keys.length];
else if (keys.length > values.length)
keys = keys[0 .. values.length];
aa = aaLiteral(keys, values);
}
alias Key = typeof(keys[0]);
alias Value = typeof(values[0]);
return (() @trusted => cast(Value[Key]) aa)();
}
@safe unittest
{
struct ThrowingElement
{
int i;
static bool b;
~this(){
if (b)
throw new Exception("");
}
}
assert(assocArray([ThrowingElement()], [0]) == [ThrowingElement(): 0]);
}