gary@SUN.MCS.CLARKSON.EDU (Gary Levin) (10/16/88)
certain prototype definitions appear not to be accepted. why does it complain about yyy, but not xxx? seems that there is a curious bug in the prototyping code. ------ char * yyy(); extern char * yyy(char *, char); char * xxx(); extern char * xxx(int,int); ----- Until it is fixed, I can't make use of the prototype checking, because the standard includes don't have the prototype info. (yyy is the same as index).
shap@polya.Stanford.EDU (Jonathan S. Shapiro) (10/17/88)
In article <8810160211.AA07329@sun.mcs.clarkson.edu> gary@SUN.MCS.CLARKSON.EDU (Gary Levin) writes: >certain prototype definitions appear not to be accepted. > >why does it complain about yyy, but not xxx? seems that there is a >curious bug in the prototyping code. > >------ >char * yyy(); >extern char * yyy(char *, char); > >char * xxx(); >extern char * xxx(int,int); >----- > >Until it is fixed, I can't make use of the prototype checking, because >the standard includes don't have the prototype info. (yyy is the same >as index). It better not be fixed! It is right! The reason is this: When the compiler sees char *yyy() It assumes that all args get passed as 32 bit quantities. Once it actually knows that the size of a char is 8 bits, it is free to (consistently) pass that as an 8 bit or 16 bit quantity if the architecture allows. char *xxx(int, int) on the other hand, doesn't in any way affect arg passing on a 32 bit int machine. Therefore, char *yyy(char *, char) need not have the same stack layout as char *yyy() Jon
gary@sun.mcs.clarkson.edu (Gary Levin) (10/22/88)
Thanks to those who pointed out the relation between the old and new definitions and the old and new function heads. The ANSI standard could have been written more clearly. Warning: Borland's interpretation of the ANSI standard is off. Their view is that the prototyped definitions (i.e. prototype without the body) would control the widening effect of BOTH the call and the function head. This is convenient, but, as you have shown, wrong. My apologies for posting to the util group by mistake. Thought I'd send the thanks here, but further comments should move to gcc.bug -- ----- Gary Levin/Dept of Math & CS/Clarkson Univ/Potsdam, NY 13676/(315) 268-2384 BitNet: gary@clutx Internet: gary@clutx.clarkson.edu
paul@UUNET.UU.NET (Paul Hudson) (10/31/88)
Date: 17 Oct 88 16:45:52 GMT From: "Jonathan S. Shapiro" <acorn!labrea.stanford.edu!polya!shap> Organization: Stanford University References: <8810160211.AA07329@sun.mcs.clarkson.edu> Sender: acorn!prep.ai.mit.edu!bug-gnu-utils-request >> >> why does it complain about yyy, but not xxx? seems that there is a >> curious bug in the prototyping code. > >------ >char * yyy(); >extern char * yyy(char *, char); > >char * xxx(); >extern char * xxx(int,int); >----- > It better not be fixed! It is right! [Omitted justification about args being 32 bits, or not] NO, NO, NO. I do not want the compiler to only warn about problems that are real problems for the current target machine. If it can cause a problem on any reasonable machine, I want to know about it. It's taken years to clear most of the "ints are the sme as longs - since *everyone* has a Vax" - let's try for portable code, no? Paul Hudson Snail mail: Monotype ADG Email: ...!ukc!acorn!moncam!paul Science Park, paul@moncam.co.uk Milton Road, "Sun Microsysytems: Cambridge, The Company is Arrogant (TM)" CB4 4FQ