|
![]() Click on image to see enlargment |
|
PC-lint/FlexeLint Output | Reference Manual Explanation | Home bug1401.cpp
For New Year's Eve, James Bond orders his usual martini but has it analyzed first. One of the ingredients is suspiciously off. Which one? bug1401.cpp lint Output--- Module: bug1401.cpp (C++)
_
{ vermouth = .10; gin = .90; }
bug1401.cpp(9) : Warning 1401: member 'Drink::ice' (line 4) not initialized by constructor
_
{ vermouth = .10; gin = .90; }
bug1401.cpp(9) : Warning 1401: member 'Drink::scotch' (line 5) not initialized by constructor
--- Wrap-up for Module: bug1401.cpp
Info 749: local enumeration constant 'Drink::Ice::stirred' (line 4, file bug1401.cpp) not referenced
Reference Manual Explanation
1401 member 'Symbol' (Location) not initialized by constructor -- The indicated
member symbol was not initialized by a constructor. Was this an oversight?
CommentaryWe've been asked to comment on the bug of the month, in addition to providing exactly and precisely what our lint product and its accompanying documentation gives you. So here goes:For one thing, this example demonstrates a shortcoming of this and all other static analyzers. The problem, of course, is that James Bond preferred Vodka Martinis and not Gin Martinis Aside from this glaring error, we have one stemming from the subtleties and bewildering varieties of initialization in C++. C++ supports copy initialization, direct initialization, dynamic initialization, default initialization, explicit initialization, no initialization, static initialization, value initialization and zero initialization, and it's easy to forget which applies in a given situation. In Mr. Bond's case, "no initialization" would apply to the amount of scotch in the drinks and so this component's value resembles noise.
When we ran the program we got the values: If you have comments or questions about this bug, please post them to our Discussion Forum |
Previous Bug - Bug #774 - December 2006