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

            bug1729.cpp

1   class X
2       {
3       public:
4       int upper;
5       int lower;
6       X( int init ) : lower( init ), upper( lower+1 )
7           {}
8       };
9
10  X x(1);

This programmer expected the value of lower and upper of object x to be initialized to 1 and 2 respectively; instead, both were given the same value (1). How come?


bug1729.cpp lint Output

--- Module:   bug1729.cpp
                                            _
        X( int init ) : lower( init ), upper( lower+1 )
bug1729.cpp  6  Info 1729: Initializer inversion detected for member 'X::upper'
        _
        };
bug1729.cpp  8  Info 1712: default constructor not defined for class 'X'

Reference Manual Explanation

 
1729  Initializer inversion detected for member 'Symbol'  -- In
      a constructor initializer the order of evaluation is
      determined by the member order not the order in which the
      initializers are given.  At least one of the initializers
      was given out of order. Was there a reason for this?  Did
      the programmer think that by changing the order that
      he/she would affect the order of evaluation?  Place the
      initializers in the order of their occurrence within the
      class so that there can be no mistaken assumptions.
      [12, Item 13]

Previous Bug - Bug #613 - February 2002

PC-lint/FlexeLint - Product Overview

Home | Contact | Order

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