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

            bug561.cpp

1     #include <stdio.h>
2
3     typedef short int Integer;
4     const char *input = "3 4 5";
5     Integer a[3];
6     #define x a[2]
7     #define y a[1]
8     #define z a[0]
9
10    int main()
11        {
12        sscanf( input, "%d %d %d", &x, &y, &z );
13        if( x*x + y*y == z*z )
14            printf( "%s is a right triangle\n", input );
15        else
16            printf( "%s is not a right triangle\n", input );
17        return 0;
18        }

The programmer thought that he was losing his mind as his program  was reporting that 3 4 5 was not a right triangle.  What could possibly be the problem?


bug561.cpp lint Output

--- Module:   bug561.cpp
                                           _
    sscanf( input, "%d %d %d", &x, &y, &z );
bug561.cpp(12) : Warning 561: (arg. no. 3) indirect object inconsistent with format
bug561.cpp(12) : Warning 561: (arg. no. 4) indirect object inconsistent with format
bug561.cpp(12) : Warning 561: (arg. no. 5) indirect object inconsistent with format

Reference Manual Explanation

561   (arg. no. Integer) indirect object inconsistent with format  -- The given
      argument (to scanf, sscanf, or fscanf) was a pointer to an object that was
      inconsistent with that which was anticipated as the result of analyzing
      the format string.  Argument counts begin at 1 and include file, string
      and format specifications.  For example if n is declared as int then:

                scanf( "%c", &n )

      will elicit this message for argument number 2.

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

Previous Bug - Bug #525 - July 2003

PC-lint/FlexeLint - Product Overview

Home | Contact | Order

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