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

            bug602.cpp

1    #include <stdio.h>
2
3    int quotient(int *q, int *p)
4        {
5        if(*p) return *q/*p  /* compute ratio */ ;
6        else return *q;
7        }
8
9    int main()
10       {
11       int n = 20, m = 4;
12       int q = quotient( &n, &m );
13       printf( "%d/%d == %d\n", n, m, q );
14       return 0;
15       }

The programmer was surprised when his program reported that 20 / 4 equaled 20. What's going wrong?


bug602.cpp lint Output

--- Module:   bug602.cpp
                           _
    if(*p) return *q/*p  /* compute ratio */ ;
bug602.cpp(5) : Warning 602: Comment within comment


Reference Manual Explanation

 
602    Comment within comment  -- The sequence /* was found within a
       comment.  Was this deliberate? Or was a comment end inadvertently
       omitted?  If you want FlexeLint/PC-lint to recognize nested
       comments you should set the Nested Comment flag using the +fnc
       option.  Then this warning will not be issued.  If it is your
       practice to use

                 /*
                 /*            */

       then use -e602.


Previous Bug - Bug #1529 - January 2001

PC-lint/FlexeLint - Product Overview

Home | Contact | Order

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