Skip to content

Commit

Permalink
Merge pull request #4778 from WalterBright/fix14510
Browse files Browse the repository at this point in the history
Critical: fix Issue 14510 - Bad tail call optimization with static arrays
  • Loading branch information
9rnsr committed Jun 27, 2015
2 parents d8eb139 + af82ac6 commit 6071f1d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/backend/gloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,8 @@ STATIC void movelis(elem *n,block *b,loop *l,int *pdomexit)
// first block of the function. Unfortunately, the rd vector
// does not take this into account. Therefore, we assume the
// worst and reject assignments to function parameters.
if (v->Sclass == SCparameter || v->Sclass == SCregpar || v->Sclass == SCfastpar)
if (v->Sclass == SCparameter || v->Sclass == SCregpar ||
v->Sclass == SCfastpar || v->Sclass == SCshadowreg)
goto L3;

if (el_sideeffect(n->E2)) goto L3; // case 5
Expand Down
20 changes: 20 additions & 0 deletions test/runnable/test42.d
Original file line number Diff line number Diff line change
Expand Up @@ -5994,6 +5994,25 @@ void test14430(){
setCookie();
}

/***************************************************/
// 14510

alias Vector14510 = ulong[3];

void fun14510(Vector14510 vec, bool recursive = false)
{
assert(vec[2] == 0);
if (recursive)
return;
fun14510(vec, true);
}

void test14510()
{
Vector14510 vec;
fun14510(vec);
}

/***************************************************/

int main()
Expand Down Expand Up @@ -6289,6 +6308,7 @@ int main()
test7436();
test12138();
test14430();
test14510();

writefln("Success");
return 0;
Expand Down

0 comments on commit 6071f1d

Please sign in to comment.