Click on image to see enlargment

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

            bug505.cpp

1    #include <stdio.h>
2    #include <string.h>
3
4    char April[] = "April";
5    void swap( char *p, char *q )
6        { char t = *p; *p = *q; *q = t; }
7    void reverse( char *s, size_t len )
8        {
9        char *top, *bot;
10       for( bot = s, top = s+len-1;
11              bot < top, *bot;
12                bot++, top-- )
13           swap( bot, top );
14       }
15   int main()
16       {
17       reverse( April, strlen(April) );
18       printf( "%s\n", April );
19       return 0;
20       }

In an April Fool's prank, Letterman wanted to reverse the letters of "April" but was foiled in his attempt; the program prints "April". Where is his bug?


bug505.cpp lint Output


--- Module:   bug505.cpp (C++)
                          _
           bot < top, *bot;
bug505.cpp(11) : Warning 505: Redundant left argument to comma

Reference Manual Explanation


505    Redundant left argument to comma  -- The left argument to the comma
       operator had no side effects in its top-most operator and hence is redundant.


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


Previous Bug - Bug #573 - March 2007

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