|
![]() Click on image to see enlargment |
|
PC-lint/FlexeLint Output | Reference Manual Explanation | Home bug687.cpp
The UN commission on climate requested that Santa measure green house gas emissions from his reindeer. After gathering the data (phew, what a job) and running this program, he got strange results for non-Rudolph reindeer. Can you spot the problem? bug687.cpp lint Output
--- Module: bug687.cpp (C++)
_
total += p->no2 * 297.4;
bug687.cpp(15) : Warning 687: Suspicious use of comma
_
}
bug687.cpp(18) : Info 818: Pointer parameter 'p' (line 10) could be declared as pointing to const
Reference Manual Explanation
687 Suspicious use of comma operator -- A comma operator appeared unbraced and
unparenthesized in a statement following an if, else, while or for clause.
For example:
if( n > 0 ) n = 1,
n = 2;
Thus the comma could be mistaken for a semi-colon and hence be the source of
subtle bugs.
If the statement is enclosed in curly braces or if the expression is enclosed
in parentheses, the message is not issued.
If you have comments or questions about this bug, please post them to our Discussion Forum |
Previous Bug - Bug #591 - November 2009