Click on image to see enlargment

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

            bug521.cpp

1    #include <stdio.h>
2
3    double scores[] = { 67 , 87 , 100 } ;
4    int nscores = 3 ;
5
6    double average ( )
7        {
8        double sum = 0 ;
9        for( int n = 0 ; n < nscores ;  + + n )
10           {
11           sum += scores [ n ] ;
12           }
13       return sum / nscores ;
14       }
15
16   int main ( )
17       {
18       printf( "The average score in the quiz " ) ;
19       printf( "was %g \n" , average ( ) ) ;
20       return 0 ;
21       }

Eager to automate the dreary drudgery of grading students, a teacher began by writing a simple program to compute the average of the student's grades using a sample of simple test data. But it seems to be taking a long time. What's the problem?


bug521.cpp lint Output

--- Module:   bug521.cpp (C++)
                                          _
    for( int n = 0 ; n < nscores ;  + + n )
bug521.cpp(9) : Warning 521: Expected void type, assignment, increment or
    decrement

Reference Manual Explanation


521    Expected void type, assignment, increment or decrement.  -- The
       third expression of a for clause should either be an expression
       yielding the void type or be one of the privileged operators:
       assignment, increment, or decrement.  See also message 522

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

Previous Bug - Bug #681 - August 2006

[ new ] 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 2006, Gimpel Software, All rights reserved.