Click on image to see enlargment
Al Gonquin, a native American, but proud of his family's history of fighting for independence, wants to celebrate Flag Day by writing a program to display a smallish version of an American flag with the field of stars computed by the function shown. Unfortunately the code has a slight flaw. Can you find it?
bug662.cpp lint Output
--- Module: bug662.cpp (C++) _ stars[i][j] = (i+j) % 2 ? ' ' : '*'; bug662.cpp 7 Warning 662: Possible creation of out-of-bounds pointer (12 beyond end of data) by operator '[' [Reference: file bug662.cpp: lines 5, 6, 7] bug662.cpp 7 Warning 661: Possible access of out-of-bounds pointer (12 beyond end of data) by operator '[' [Reference: file bug662.cpp: lines 5, 6, 7] --- Global Wrap-up Info 714: Symbol 'fill_stars(void)' (line 2, file bug662.cpp) not referenced Warning 552: Symbol 'stars' (line 1, file bug662.cpp) not accessed
Reference Manual Explanation
662 possible creation of out-of-bounds pointer ('Integer' beyond end of data) by operator 'String' -- An out-of-bounds pointer may have been created. See message 415 for a description of the parameters Integer and String. For example: int a; if( n <= 20 ) f( a + n ); Here, it appears as though an illicit pointer is being created, but PC-lint/FlexeLint cannot be certain. See also messages 416 and 797.
If you have comments or questions about this bug, please post them to our Discussion Forum
Previous Bug - Bug #1568 - May 2011