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

bug563.c

1    #include <stdio.h>
2
3    int f(int n)
4        {
5        int m;
6        switch( n )
7            {
8        case 1: m = 2; break;
9        case 2: m = 4; break;
10       case 3: m = 8; break;
11       delault: m = 0; break;
12           }
13       return m;
14       }
15
16   int main()
17       {
18       printf( "f(5) = %d\n", f(5) );
19       return 0;
20       }

This program has an interesting flaw that causes it to print garbage. The flaw is sufficiently obscure that the problem was reported to IBM as a compiler bug. Mr. Bernd Kunrath of Stuttgart uncovered the flaw by running the code against PC-lint. Can you spot it?

bug563.c lint Output

--- Module:   bug563.c
        _
        }
bug563.c(12) : Info 744: switch statement has no default
            _
    return m;
bug563.c(13) : Warning 644: m (line 5) may not have been initialized
    _
    }
bug563.c(14) : Warning 563: Label delault (line 11) not referenced

Reference Manual Explanation

 563    Label Symbol (Location) not referenced  -- The Symbol at the
        cited Location appeared as a label but there was no statement
        that referenced this label.

Previous Bug - Bug # 1532 - March 1997
Next Bug - Bug # 1506 - May 1997

PC-lint/FlexeLint - Product Overview

Home | Contact | Order

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