Click on image to see enlargment

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

            bug559.cpp

1    #include <stdio.h>
2
3    typedef double Temp;
4    #define Smoke 1.002
5    #define Mirror 1.001
6
7    Temp annual_delta( Temp t, double grants, double press_covrg )
8        {
9        return t * Smoke * grants * Mirror * press_covrg;
10       }
11   int main()
12       {
13       1Temp t = 72.3;      // initial temperature
14       int years = 10;
15       do  {
16           printf( "%d\n", t );
17           t = annual_delta( t, 1.002, 1.002 );
18           } while( years-- );
19       return 0;
20       }

Prof. Otidnab is preparing a report to display his latest atmospheric temperature model. But he's getting results that even he doesn't believe. Can you find the problem?


bug559.cpp lint Output

--- Module:   bug559.cpp (C++)
                          _
        printf( "%d\n", t );
bug559.cpp(16) : Warning 559: Size of argument no. 2 inconsistent with format

Reference Manual Explanation


559    size of argument number Integer inconsistent with format  -- The
       given argument (to printf, sprintf, or fprintf) 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,

               sprintf( buffer, "%f", 371 )

       will show an error in argument number 3 because constant 371 is
       not floating point.




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


Previous Bug - Bug #564 - December 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 2012, Gimpel Software, All rights reserved.