Skip to content

Commit

Permalink
Merge pull request #6261 from WalterBright/fix16699
Browse files Browse the repository at this point in the history
fix Issue 16699 - [REG 2.070] stack corruption with scope(exit)
  • Loading branch information
MartinNowak authored Nov 19, 2016
2 parents b2691f3 + a96a3f9 commit 7776ed4
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 7776ed4

Please sign in to comment.