Click on image to see enlargment

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


1    #include <stdio.h>
3    typedef const char *S;
4    typedef char Player[100];
6    void asgn_position( Player name, S pos )
7        {
8        sprintf( name, "%s %s", pos, name );
9        }
11   int main()
12       {
13       Player player = "Joe Jackson";
14       asgn_position( player, "QB" );
15       printf( "%s\n", player );
16       return 0;
17       }

The football coach wanted to prefix a position indicator before each player so that in this example he would get "QB Joe Jackson". But something went wrong. Can you spot the problem?

bug464.cpp lint Output

--- Module:   bug464.cpp (C++)
    sprintf( name, "%s %s", pos, name );
bug464.cpp(8) : Warning 464: Buffer argument will be copied into itself

Reference Manual Explanation

464    Buffer argument will be copied into itself  -- This is issued
       when we encounter a function argument expression used in such a
       way that there will be an attempt to copy its contents onto
       itself.  E.g.

             sprintf( s, "%s", s );

If you have comments or questions about this bug, please post them to our   Discussion Forum

Previous Bug - Bug #440 - October 2008

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 2009, Gimpel Software, All rights reserved.