Skip to content

Commit

Permalink
fix Issue 16699 - [REG 2.070] stack corruption with scope(exit)
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright authored and Dicebot committed Nov 19, 2016
1 parent b2691f3 commit a96a3f9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/backend/cgelem.c
Expand Up @@ -5353,7 +5353,7 @@ elem *doptelem(elem *e, goal_t goal)

/* If entire expression is a struct, and we can replace it with */
/* something simpler, do so. */
if (goal & GOALstruct && e && tybasic(e->Ety) == TYstruct)
if (goal & GOALstruct && e && (tybasic(e->Ety) == TYstruct || tybasic(e->Ety) == TYarray))
e = elstruct(e, goal);

return e;
Expand Down
2 changes: 1 addition & 1 deletion src/backend/el.c
Expand Up @@ -3226,7 +3226,7 @@ void elem_print(elem *e)
else
{
if ((e->Eoper == OPstrpar || e->Eoper == OPstrctor || e->Eoper == OPstreq) ||
e->Ety == TYstruct)
e->Ety == TYstruct || e->Ety == TYarray)
if (e->ET)
dbg_printf("%d ", (int)type_size(e->ET));
WRTYxx(e->Ety);
Expand Down
24 changes: 24 additions & 0 deletions test/runnable/mars1.d
Expand Up @@ -1454,6 +1454,29 @@ void writeln(int v, int[] a)

////////////////////////////////////////////////////////////////////////

// https://issues.dlang.org/show_bug.cgi?id=16699

ulong[1] parseDateRange()
{
try
{
ulong[1] result;
result[0] = 6;
return result;
}
finally
{
}
}

void test16699()
{
ulong[1] range = parseDateRange();
assert(range[0] == 6);
}

////////////////////////////////////////////////////////////////////////

int main()
{
testgoto();
Expand Down Expand Up @@ -1504,6 +1527,7 @@ int main()
test15272();
test15861();
test15629();
test16699();
printf("Success\n");
return 0;
}

0 comments on commit a96a3f9

Please sign in to comment.