Click on image to see enlargment
Shawn O'Flaherty, perhaps a bit tipsy when he wrote this, is preparing a program for his pub's annual St. Patrick's Day celebration. Although not finished, there's already a bit of a problem. Can you find it?
bug415.cpp lint Output
--- Module: bug415.cpp (C++) _ drinks[sizeof(drinks)/sizeof(drinks)].id; bug415.cpp(19) : Warning 415: Likely access of out-of-bounds pointer (1 beyond end of data) by operator '[' [Reference: file bug415.cpp: line 19] _ i++ ) bug415.cpp(20) : Warning 441: for clause irregularity: loop variable 'i' not found in 2nd for expression bug415.cpp(19) : Warning 415: Likely access of out-of-bounds pointer (1 beyond end of data) by operator '[' [Reference: file bug415.cpp: line 19]
Reference Manual Explanation
415 Likely access of out-of-bounds pointer ('Integer' beyond end of data) by operator 'String' -- An out-of-bounds pointer was accessed. String designates the operator. The parameter 'Integer' gives some idea how far out of bounds the pointer may be. It is measured in units given by the size of the pointed to object. The value is relative to the last item of good data and therefore should always be greater than zero. For example: int a; a = 0; results in an overflow message containing the phrase '1 beyond end of data'.
Previous Bug - Bug #414 - February 2012