Click on image to see enlargment

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

            bug602.c

1    #include <stdio.h>
2
3    int days_per_month( int n )
4        {
5    #pragma parameters_used(n)
6    #pragma op_precedence(?:+-/*)
7        if( n < 1 || n > 12 )       /* range check */
8            return 0;
9        return
10           n == 2 ? 28 :           /*  February   */
11           n >= 8 ? 31 - n % 2 :   /*  Aug - Dec  */
12           30 + n % 2;             /*  Jan - Jul  */
13       }
14
15   int main()
16       { return printf( "%d\n", days_per_month(8) ); }

Augustus found a program that when compiled and run was supposed to produce the number of days in his favorite month. But it did not. The code was originally written for a compiler that had an unusual pragma structure. What was the value that Augustus was getting and why did he get it?


bug602.c lint Output

--- Module:   bug602.c (C)
                                  _
    if( n < 1 || n > 12 )       /* range check */
bug602.c(7) : Warning 602: Comment within comment
    _
    return
bug602.c(9) : Warning 527: Unreachable code at token 'return'
bug602.c(9) : Info 1791: No token on this line follows the 'return' keyword

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 PC-lint/FlexeLint 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 the sequence:

                   /*
                   /*            */

       then use -e602.


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


Previous Bug - Bug #603 - July 2012

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.