Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: Dan.Pop@cern.ch (Dan Pop)
Subject: Re: Bug in OSF1.32 C compiler on alpha
Date: 1996/07/02	[thread overview]
Message-ID: <danpop.836269061@news.cern.ch> (raw)
In-Reply-To: 4r965l$inj@news.psc.edu


In <4r965l$inj@news.psc.edu> Nigel Goddard <ngoddard@psc.edu> 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 <stdio.h>
>
>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



  parent reply	other threads:[~1996-07-02  4:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-07-01  4:00 Bug in OSF1.32 C compiler on alpha Nigel Goddard
1996-07-01  4:00 ` Daryl Clevenger
1996-07-01  4:00 ` Steve Peltz
1996-07-02  4:00   ` Dan Pop
1996-07-08  4:00     ` Steve Peltz
1996-07-08  4:00       ` Dan Pop
1996-07-02  4:00 ` Dan Pop [this message]
1996-07-03  4:00 ` Andy V
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox