Menu

#1998 Wrong variable used due to deferred symbol binding

closed-fixed
7
2013-05-25
2012-03-30
No

In revision #7514:

int foo(void)
{
int y = 1;
{
int x = y;
int y = 2;
return x;
}
}

In the initialization of x, y should bind to the variable declared in the outer block (and will, if the declaration of y in the inner block is not present). but instead binds to the declaration of y in the inner block. The compiler notes that the inner y may be being used before initialization, does not actually apply the specified initial value to the inner y, but then returns the inner y's value since it believes that x was initialized with the inner y's value.

Discussion

  • Philipp Klaus Krause

    Increasing priority, since bad code is generated silently.

    Philipp

     
  • Philipp Klaus Krause

    • priority: 5 --> 7
     
  • Erik Petrich

    Erik Petrich - 2012-12-26
    • milestone: --> fixed
    • assigned_to: nobody --> epetrich
    • status: open --> closed-fixed
     
  • Erik Petrich

    Erik Petrich - 2012-12-26

    Fixed in revision #8280

     

Log in to post a comment.