Click on image to see enlargment

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

            bug527.cpp

1    int count_vowels( char *s )
2        {
3        int sum = 0;
4        for(;;)
5            switch( *s++ )
6                {
7            case 'a':
8            case 'e':
9            case 'i':
10           case 'o':
11           case 'u':
12               sum++; continue;
13           default:   continue;
14           case '\0': break;
15               }
16       return sum;
17       }

This function is intended to count the vowels in the string s provided as parameter, but it's taking its time about it. Can you spot the difficulty?


bug527.cpp lint Output

--- Module:   bug527.cpp (C++)
    _
    return sum;
bug527.cpp  16  Warning 527: Unreachable code at token 'return' 
    _
    }
bug527.cpp  17  Info 818: Pointer parameter 's' (line 1) could be declared as pointing to const

Reference Manual Explanation


527    Unreachable code at token Symbol  -- A portion of the program cannot be reached.


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


Previous Bug - Bug #620 - July 2010

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