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

            bug603.cpp

1    #include <stdio.h>
2
3    void string_copy( const char *, char * );
4
5    int main()
6        {
7        char buf[12];
8
9        string_copy( buf, "hello world" );
10       printf( "%s\n", buf );
11       return 0;
12       }

Our programmer in this example is employing a string copying routine from a library (the declaration has been copied from the header file and shown explicitly) but he was surprised to find that things didn't quite work out.  Why?


bug603.cpp lint Output

 --- Module:   bug603.cpp
                                    _
    string_copy( buf, "hello world" );
bug603.cpp(9) : Info 1776: Converting a string literal to char * is not const
    safe (arg. no. 2)
bug603.cpp(9) : Warning 603: Symbol 'buf' (line 7) not initialized

Reference Manual Explanation

 
603   Symbol 'Symbol' (Location) not initialized  -- The address
      of the named symbol is being passed to a function where
      the corresponding parameter is declared as pointer to
      const.  This implies that the function will not modify the
      object.  If this is the case then the original object
      should have been initialized sometime earlier.

Previous Bug - Bug

PC-lint/FlexeLint - Product Overview

Home | Contact | Order

PC-lint and FlexeLint are trademarks of Gimpel Software
Copyright © 2003, Gimpel Software