Click on image to see enlargment
Armed with a list of first grade students and their parents' political affiliation, the principal wanted to have a list of all the potential trouble makers. But in addition to something wrong with the program, there is something wrong with this program. Can you spot it?
bug444.cpp lint Output
--- Module: bug444.cpp (C++) _ for( p = A; p; p++ ) bug444.cpp(14) : Warning 444: for clause irregularity: pointer 'p' incremented in 3rd expression is tested for NULL in 2nd expression
Reference Manual Explanation
444 for clause irregularity: pointer 'Symbol' incremented in 3rd expression is tested for NULL in 2nd expression -- The following kind of situation has been detected: for( ... ; p == NULL; p++ ) ... A loop variable being incremented or decremented would not normally be checked to see if it is NULL. This is more likely a programmer error.
If you have comments or questions about this bug, please post them to our Discussion Forum
Previous Bug - Bug #777 - August 2009