From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,f4c619a88791a415 X-Google-Attributes: gid1164f8,public X-Google-Thread: 1450f6,f4c619a88791a415 X-Google-Attributes: gid1450f6,public From: Dan.Pop@cern.ch (Dan Pop) Subject: Re: Bug in OSF1.32 C compiler on alpha Date: 1996/07/02 Message-ID: #1/1 X-Deja-AN: 163206211 sender: news@news.cern.ch (USENET News System) x-nntp-posting-host: ues5.cern.ch references: <4r965l$inj@news.psc.edu> organization: CERN European Lab for Particle Physics newsgroups: comp.sys.dec,cmu.comp.sys.dec.alpha In <4r965l$inj@news.psc.edu> Nigel Goddard writes: >Is this one known? Is there a fix? Yes and yes. >Briefly, code taking the address of a function parameter declared float >in the old style is not compiled correctly. A function parameter declared float in an old style function definition has the type double. >Here is a sample program > >#include > >static void G(px) > float *px; >{ > (void) printf("%f\n", *px); >} > >static void F(x) > float x; The compiler is required to treat this declaration as double x; >{ > (void) printf("%f\n", x); > G(&x); Now you pass a pointer to double to a function expecting a pointer to float. All the bets are off. >} > >int main () >{ > F(0.2); The type of the constant 0.2 is double, but this is OK, because the function F actually expects a double argument. > return(0); >} Since the bug is in your code, _you_ have to fix it. Either by switching to ANSI prototypes or by declaring the argument of the function G as double *px; Dan -- Dan Pop CERN, CN Division Email: Dan.Pop@cern.ch Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland