[gnu.gcc.bug] Bug in gcc1.33

lenny@icus.islp.ny.us (Lenny Tropiano) (02/18/89)

There appears to be a bug in the gcc1.33 compiler with enumerated types in 
a case/switch statement.  I am running this on an UNIX PC/3B1 ... 
Here's the code that failed with gcc, and compiled fine with the stock compiler:

    1	
    2	typedef enum {
    3		apples,
    4		oranges,
    5		pears,
    6		bananas } FRUIT;
    7	
    8	FRUIT	fruit;
    9	
   10	main()
   11	{
   12		fruit = apples;
   13	
   14		switch ((int)fruit) {
   15		case (int)apples:
   16			printf("apples\n");
   17			break;
   18		case (int)oranges:
   19			printf("oranges\n");
   20			break;
   21		case (int)pears:
   22			printf("pears\n");
   23			break;
   24		case (int)bananas:
   25			printf("bananas\n");
   26			break;
   27		}
   28	}

$ gcc -v -o testenum testenum.c
gcc version 1.33
 /usr/gnu/lib/gcc-cpp -v -undef -D__GNUC__ -Dmc68k -Dunix -Dunixpc -D__mc68k__ -D__unix__ -D__unixpc__ test_enum.c /tmp/cca10154.cpp
GNU CPP version 1.33
 /usr/gnu/lib/gcc-cc1 /tmp/cca10154.cpp -quiet -dumpbase test_enum.c -version -o /tmp/cca10154.s
GNU C version 1.33 (68k, SGS/AT&T unixpc syntax) compiled by GNU C version 1.33.
test_enum.c: In function main:
test_enum.c:15: case label does not reduce to an integer constant
test_enum.c:18: case label does not reduce to an integer constant
test_enum.c:21: case label does not reduce to an integer constant
test_enum.c:24: case label does not reduce to an integer constant

$ cc -v -o testenum testenum.c
Preprocessing ...
Compiling ...
Assembling ...
Loading ...
$ testenum
apples

NOTE:  This bug was found while compiling gawk, using gcc.  It failed in
the debug.c source on a similar enumerated type case/switch statement.

-Lenny
-- 
Lenny Tropiano             ICUS Software Systems         [w] +1 (516) 582-5525
lenny@icus.islp.ny.us      Telex; 154232428 ICUS         [h] +1 (516) 968-8576
{talcott,decuac,boulder,hombre,pacbell,sbcs}!icus!lenny  attmail!icus!lenny
        ICUS Software Systems -- PO Box 1; Islip Terrace, NY  11752