Click on image to see enlargment
A political party wishing to sabotage the chances of a popular presidential candidate, modifies the vote counting program to the above. But something is not quite right. Can you spot the flaw?
bug661.cpp lint Output
--- Module: bug661.cpp (C++) _ k -= Weight[i]; bug661.cpp(13) : Warning 661: Possible access of out-of-bounds pointer (1 beyond end of data) by operator '[' [Reference: file bug661.cpp: lines 10,13]
Reference Manual Explanation
661 possible access of out-of-bounds pointer ('Integer' beyond end of data) by operator 'String' -- An out-of-bounds pointer may have been accessed. See message 415 for a description of the parameters Integer and String. For example: int a; if( n <= 10 ) a[n] = 0; Here the programmer presumably should have written n<10. This message is similar to messages 415 and 796 but differs from them by the degree of probability.
If you have comments or questions about this bug, please post them to our Discussion Forum
Previous Bug - Bug #1547 - January 2008