[tree-ssa] Handling of variable scopes?

Zdenek Dvorak rakdver@atrey.karlin.mff.cuni.cz
Fri Aug 8 19:02:00 GMT 2003


Hello,

it is probably a known issue, but anyway. During my playing with
tree-ssa branch, I encountered the following problem.  Consider
this testcase:

#include <stdio.h>

int main(void)
{
  int k;

  goto bla;
st:;

   printf("%d\n", k);
   return 0;

bla:;
    {
      int j = foo ();

      k = j;
    }

  goto st;
}

In dominator optimization, a set to k is copy propagated, thus we obtain

int main(void)
{
  goto bla;
st:;

   printf("%d\n", j);
   return 0;

bla:;
    {
      int j = foo ();
    }

  goto st;
}

j is now out of its scope, which is plainly wrong and causes ICE when
the variable is referenced the first time (I have tried to persuade gcc
to actually misscompile something this way, but I have failed; but I
don't much doubt that it is possible).

Zdenek



More information about the Gcc mailing list