Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!husc6!rutgers!clyde!burl!codas!mtune!lzaz!lznv!psc
From: psc@lznv.ATT.COM (Paul S. R. Chisholm)
Newsgroups: comp.sys.ibm.pc
Subject: Re: Problems with MSC 5.0 (typedefs become reserved words?)
Message-ID: <1210@lznv.ATT.COM>
Date: Wed, 2-Dec-87 14:04:30 EST
Article-I.D.: lznv.1210
Posted: Wed Dec  2 14:04:30 1987
Date-Received: Mon, 7-Dec-87 06:44:41 EST
References: <754@pilchuck.Data-IO.COM> <1610047@hpcvlo.HP.COM> <1203@lznv.ATT.COM> <2355@emory.uucp>
Organization: AT&T
Lines: 41
Summary: Where the problem is, and when it seems to work



In article <2355@emory.uucp>, platt@emory.uucp (Dan Platt) writes:
> In article <1203@lznv.ATT.COM> psc@lznv.ATT.COM (Paul S. R. Chisholm) writes:
> >In article <1610047@hpcvlo.HP.COM>, jason@hpcvlo.HP.COM (Jason Su) writes:
> >> /* Here's another irritating bug that compiled(!) w/o errors on MSC 4.0. */
> >> typedef int map;
> >> 
> >> typedef struct {
> >> 	int *map;		/* <-- This is the error line */	
> >> } my_struct;		
Jason complained that the program no longer compiled under MSC 5.0.

And I said (after a reference to K&R p. 200):
> >The identifier "map" is effectively a reserved keyword from the time
> >its typedef is complete through the end of the compiled module.  MSC
> >4.0 was incorrect in accepting this code in the first place.  I suspect
> >that most C compilers that support typedef will reject it.

Well, it sounded good at the time.  But both Turbo C and the VAX UNIX
System V Release 2 compiler accepted it.  (Hey, what do I know?  I
haven't looked at the compiler's source code since System III!-)  I
wouldn't be surprised if ANSI specifically states that the above code
is legal.  If so (and people have said so in other messages), MS blew
it.

And Dan responded:
> Actually, in this case, if the error is in the line indicated by the
> comment, then there is a problem with the compiler.  The reserved word
> is 'my_struct', not 'map'.

Um, no.  In some compilers, the typedef on line one would make "map"
(effectively) a reserved identifier.  Then the field declaration on
line four fails, because "map" is no longer recognized as a possible
user identifier; it's like saying "int *float;".  (I would expect Dan's
program to compile successfully even under limited compilers that broke
on the example above.)

-Paul S. R. Chisholm, {ihnp4,cbosgd,allegra,rutgers}!mtune!lznv!psc
AT&T Mail !psrchisholm, Internet psc@lznv.att.com
I'm not speaking for my employer, I'm just speaking my mind.