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

            bug1741.cpp

1     #include <stdio.h>
2
3     class A
4         {
5        public:
6         int len;            // length of array
7         int a[10];          // the array
8         A( int n = 0 )
9             {
10            if( n >= 10 ) n = 10;
11            for( int i = 0; i < n; i++ )
12                a[i] = 0,
13            len = n;
14            }
15        int get( int i ) const
16            { return i < len ? a[i] : 0; }
17        };
18
19    int main()
20        { A a; printf( "%d\n", a.get(10) ); return 0; }

The result of running this program printed the expected '0' using one compiler but produced a very large number using another. Why the difference? Hint: this will require a degree of visual acuity.


bug1741.cpp lint Output

--- Module:   bug1741.cpp
        _
        }
bug1741.cpp(14) : Info 1741: member 'A::len' (line 6) conceivably not initialized by constructor
        _
        }
bug1741.cpp(14) : Info 1741: member 'A::a' (line 7) conceivably not initialized by constructor

Reference Manual Explanation

 
1741  member  'Symbol' (Location) conceivably not initialized by constructor  -- The
      indicated member symbol may not have been initialized by a constructor.  Was this
      an oversight? There appears to be a path through a loop that does initialize the
      member and the warning is issued because it is not clear that the loop is always
      executed at least once.

If you have comments or questions about this bug, please post them to our   Discussion Forum

Previous Bug - Bug #1540 - March 2003

PC-lint/FlexeLint - Product Overview

Home | Contact | Order

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