Click on image to see enlargment

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

            bug1541.cpp

1    #include <stdio.h>
2    enum Bread { white, rye, wheat };
3    typedef const char *Str;
4    class Sandwich
5        {
6        Str name, ingred1, ingred2;
7        Bread bread;
8      public:
9        Sandwich( Str nm, Str ig1, Str ig2, Bread  br )
10           {
11           name = nm;
12           ingred1 = ig1;
13           if( ig2 ) ingred2 = ig2;
14           bread = br;
15           }
16       void ingredients()
17           { printf( "%s %s %d\n", ingred1, ingred2, bread ); }
18       };
19   int main()
20       {
21       Sandwich bh( "Bob Hope", "ham", "cheese", rye );
22       Sandwich ld( "Larry David", "Whitefish", NULL, wheat );
23       ld.ingredients();
24       return 0;
25       }

Nathan is opening a restaurant with a celebrity line of sandwiches. Unfortunately the program occasionally bombs. What's going on?


bug1541.cpp lint Output

--- Module:   bug1541.cpp (C++) 
        _
        }
bug1541.cpp(15) : Warning 1541: Member 'Sandwich::ingred2' (line 6) possibly not initialized
    by constructor 
    _
    };
bug1541.cpp(18) : Info 1712: default constructor not defined for class 'Sandwich'
    _
    }
bug1541.cpp(25) : Info 1788: Variable 'bh' (line 21) (type 'Sandwich') is referenced only
    by its constructor or destructor

    --- Wrap-up for Module: bug1541.cpp

Info 749: local enumeration constant 'Bread::white' (line 2, file bug1541.cpp) not referenced
 

Reference Manual Explanation


1541   member 'Symbol' (Location) possibly not initialized by constructor  -- The indicated
       member symbol may not have been initialized by a constructor.  Was this an oversight?
       Some of the paths that the constructor takes do initialize the member.


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


Previous Bug - Bug #662 - June 2011

Use our Interactive Demo to Run FlexeLint on our Bugs of the Month

PC-lint/FlexeLint - Product Overview

Home | Contact | Order

PC-lint and FlexeLint are trademarks of Gimpel Software
Copyright 2011, Gimpel Software, All rights reserved.