🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.bugs.4bsd
Article #127

Re: PCC enum bug

#127
From: Chris Torek
Date: Sat, 14 Oct 1989 06:42
48 lines
1817 bytes
In article <20046@mimsy.UUCP> I posted a fix to pcc for

	enum this { that = 3 };
	main() {
		enum this { that = 3 };
		printf("I expect 3; I got %d\n", that);
		return (0);
	}

which produces

	I expect 3; I got 4

from many Unix C compilers.  Unfortunately, that fix accepted `benign'
redefinitions such as

	enum color { red, blue, peach };
	enum fruit { apple, pear, peach };

which are (according to the draft ANSI C standard) illegal.

Here is a different (shorter!) fix, which seems to work, and rejects
such redefinitions, while allowing local redefinitions (which persist
until a close brace).  I do not know why the psave() was there
before---it seems to have to do with debugger information and/or
disambiguation among nonunique structure member names---but taking it
out completely seems to do the trick.

[/usr/src/lib/mip/pftn.c]
RCS file: RCS/pftn.c,v
retrieving revision 1.3
retrieving revision 1.6
diff -c2 -r1.3 -r1.6
*** /tmp/,RCSt1000933	Sat Oct 14 02:39:42 1989
--- pftn.c	Sat Oct 14 02:39:42 1989
***************
*** 218,224 ****
  
  	case MOE:
- 		if( scl == class ){
- 			if( p->offset!= strucoff++ ) break;
- 			psave( idp );
- 			}
  		break;
--- 218,221 ----
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@cs.umd.edu	Path:	uunet!mimsy!chris
Technical Details
Message-ID: <20175@mimsy.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!ginosko!aplcen!haven!mimsy!chris
References: <5600@portia.Stanford.EDU> <20041@mimsy.UUCP> <20046@mimsy.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!ginosko!aplcen!haven!mimsy!chris
From: chris@mimsy.UUCP (Chris Torek)
Newsgroups: comp.bugs.4bsd
Subject: Re: PCC enum bug
Keywords: enum bug C compiler
Message-ID: <20175@mimsy.UUCP>
Date: 14 Oct 89 06:42:56 GMT
References: <5600@portia.Stanford.EDU> <20041@mimsy.UUCP> <20046@mimsy.UUCP>
Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742
Lines: 48