PC-lint/FlexeLint Output | Reference Manual Explanation | Home Page

bug578.c

1     #include <math.h>
2     #include <stdio.h>
3     typedef int WORD;
4
5     void f( WORD w )
6        {
7         if( w )
8             {
9             WORD *pow = NULL;
10            if( w > 0 && w <= 100 ) pow = &w;
11            if( !pow ) w = 100;
12            }
13        if( w )
14            {
15            if( pow ) printf( "word = %d\n", w );
16            }
17        }
18
19    int main()
20        { f( 113 ); return 0; }

To the programmer's surprise, the value 100 was printed. After discovering the problem, he began to wonder why no compiler diagnostic was issued for such a blatant error.

bug578.c lint Output

--- Module:   bug578.c
                  _
        WORD *pow = NULL;
bug578.c  9  Warning 578: Declaration of 'pow' hides 'pow(double, double)'
    (line 168, file c:\msvc\include\math.h)
                _
        if( pow ) printf( "word = %d\n", w );
bug578.c  15  Warning 506: Constant value Boolean

Reference Manual Explanation

 578  Declaration of Symbol hides Symbol (Location)  -- A
       local symbol has the identical name as a global symbol (or
       possibly another local symbol).  This could be dangerous.
       Was this deliberate?  It is usually best to rename the local
       symbol.

Previous Bug - Bug #1538 - September 1997
Next Bug - Bug #669 - November 1997

PC-lint/FlexeLint - Product Overview

Home | Contact | Order

PC-lint and FlexeLint are trademarks of Gimpel Software
Copyright © 2003, Gimpel Software