Skip to content

Commit

Permalink
Merge pull request #4841 from WalterBright/fix14829
Browse files Browse the repository at this point in the history
fix Issue 14829 - [REG2.066.0] wrong code with -O -inline
  • Loading branch information
9rnsr committed Jul 28, 2015
2 parents 56add65 + bc2ae82 commit 88bb355
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/backend/gother.c
Expand Up @@ -1101,21 +1101,14 @@ STATIC void cpwalk(elem *n,vec_t IN)
* g = v => g = f
* f = x
* d = g => d = f !!error
* Therefore, if g appears as an rvalue in expnod[], then recalc
* Therefore, if n appears as an rvalue in expnod[], then recalc
*/
for (size_t i = 1; i < exptop; ++i)
{
//printf("expnod[%d]: ", i); elem_print(expnod[i]);
if (expnod[i]->E2 == n)
{
symbol *g = expnod[i]->E1->EV.sp.Vsym;
for (size_t j = 1; j < exptop; ++j)
{
if (expnod[j]->E2->EV.sp.Vsym == g)
{
++recalc;
break;
}
}
++recalc;
break;
}
}
Expand Down
21 changes: 21 additions & 0 deletions test/runnable/mars1.d
Expand Up @@ -1324,6 +1324,26 @@ char[] dup(char[] a)
return a;
}

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

int stripLeft(int str, int dc)
{
while (true)
{
int a = str;
int s = a;
str += 1;
if (dc) return s;
}
}

void test14829()
{
if (stripLeft(3, 1) != 3) // fails with -O
assert(0);
}


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

int main()
Expand Down Expand Up @@ -1368,6 +1388,7 @@ int main()
test12057();
test13784();
test14220();
test14829();
printf("Success\n");
return 0;
}

0 comments on commit 88bb355

Please sign in to comment.