Click on image to see enlargment

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

            bug560.cpp

1    #include <stdio.h>
2    class Port
3        {
4      public:
5        double latitude, longitude;
6        const char *name;
7        operator const char* () const { return name; }
8        };
9    const Port itinerary[3] = {
10       { 55.7, 12.6, "Copenhagen" },
11       { 59.3, 18.1, "Stockholm" },
12       { 60.17, 25.0, "Helsinki" },
13       };
14   int main()
15       {
16       for( int i = 0; i < 3; i++ )
17           printf( "Port #%d, %s\n",
18               i+1, itinerary[i] );
19       return 0;
20       }

A cruise line is automating its services but there is something seriously wrong with this program. Can you spot it?


bug560.cpp lint Output


--- Module:   bug560.cpp (C++)
                              _
            i+1, itinerary[i] );
bug560.cpp(18) : Warning 560: argument no. 3 should be a pointer
bug560.cpp(18) : Warning 437: Passing struct 'Port' to ellipsis

    --- Wrap-up for Module: bug560.cpp

Info 754: local structure member 'Port::latitude' (line 5, file bug560.cpp) not referenced
Info 754: local structure member 'Port::longitude' (line 5, file bug560.cpp) not referenced
 

Reference Manual Explanation


560    argument no. Integer should be a pointer  -- The given argument (to one of the
       scanf or printf family of functions) should be a pointer.  For the scanf family,
       all arguments corresponding to a format specification should be pointers to areas
       that are to be modified (receive the results of scanning).  For the printf
       family, arguments corresponding to %s or %n also need to be pointers.

       Argument counts begin at 1 and include file, string and format specifications.
       For example

               scanf( "%f", 3.5 )

       will generate the message that argument no. 2 should be a pointer.


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


Previous Bug - Bug #1541 - July 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.