🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #2322

Bug in gcc1.33

#2322
From: Lenny Tropiano
Date: Sat, 18 Feb 1989 07:43
62 lines
2413 bytes
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
Technical Details
Message-ID: <613@icus.islp.ny.us>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cwjcc!tut.cis.ohio-state.edu!osu-cis!att!icus!lenny

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cwjcc!tut.cis.ohio-state.edu!osu-cis!att!icus!lenny
From: lenny@icus.islp.ny.us (Lenny Tropiano)
Newsgroups: gnu.gcc.bug,unix-pc.bugs
Subject: Bug in gcc1.33
Keywords: bug, case, enum, casting
Message-ID: <613@icus.islp.ny.us>
Date: 18 Feb 89 07:43:31 GMT
Organization: ICUS Software Systems, Islip, New York
Lines: 62