Click on image to see enlargment

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


1    int scores[19];
2    int hole = 0;
3    bool done = false;
4    void increment( int *p )
5        { *p++; }
6    void ball_is_struck()
7        {
8        increment( &scores[hole] );
9        }
10   void new_hole()
11       {
12       if( hole == 18 )
13           done = true;
14       else increment( &hole );
15       }

Larry, a great inventor, but a novice programmer and golfer, is attempting to automate his scoring with a special device that contains software that will call "ball_is_struck()" each time it hears the ball being struck and "new_hole()" every time a new hole is reached. But something's going wrong. His scores couldn't be that low.

bug522.cpp lint Output

--- Module:   bug522.cpp (C++)
    { *p++; }
bug522.cpp  5  Warning 522: Expected void type, assignment, increment or decrement
bug522.cpp  5  Info 818: Pointer parameter 'p' (line 4) could be declared as pointing to const

Reference Manual Explanation

522    Expected void type, assignment, increment or decrement.  -- If a statement consists
       only of an expression, it should either be an expression yielding the void type or
       be one of the privileged operators: assignment, increment, or decrement.  Note that
       the statement *p++; draws this message but p++; does not.  This message is frequently
       given in cases where a function is called through a pointer and the return value is
       not void.  In this case we recommend a cast to void.  If your compiler does not
       support the void type then you should use the -fvo option.

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

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