Menu

#296 Local Variable Gets Trashed by Temporary

closed-wont-fix
None
5
2013-05-25
2002-02-13
No

Hi,
In the following code, the local variable 'b' gets overwritten when the line 'a += f2()'
executes.

Geoffrey

#pragma CALLEE-SAVES f2
long f2( void );

long f1( void )
{
unsigned char i, j;
long a, b;

j = 10;
do
{
i = 5;
a = 0;
do
a += f2();
while( --i );

if( j==10 )
b = a;
else
a -= b;
}
while( --j );

return a;
}

Discussion

  • Sandeep Dutta

    Sandeep Dutta - 2002-02-13

    Logged In: YES
    user_id=1551

    This problem can be fixed by initializing 'b' during
    declaration .. the data flow analysis will have to be
    changed substantially to handle this situation.

     
  • Sandeep Dutta

    Sandeep Dutta - 2002-02-13
    • milestone: --> known_bugs
    • assigned_to: nobody --> sandeep
    • status: open --> closed-wont-fix
     

Log in to post a comment.