Click on image to see enlargment

PC-lint/FlexeLint Output | Reference Manual Explanation | Home

            bug662.cpp

1    char stars[9][11];
2    void fill_stars()
3        {
4        int i, j;
5        for( i = 0; i <= 9; i++ )
6            for( j = 0; j <= 11; j++ )
7                stars[i][j] = (i+j) % 2 ? ' ' : '*';
8        }

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[10];
               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

Use our Interactive Demo to Run FlexeLint on our Bugs of the Month

PC-lint/FlexeLint - Product Overview

Home | Contact | Order

PC-lint and FlexeLint are trademarks of Gimpel Software
Copyright 2011, Gimpel Software, All rights reserved.