Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!crdgw1!underdog!volpe From: volpe@underdog.crd.ge.com (Christopher R Volpe) Newsgroups: comp.lang.c Subject: Re: Nasty bug Message-ID: <11477@crdgw1.crd.ge.com> Date: 30 Aug 90 18:17:11 GMT References: <2020@engage.enet.dec.com> Sender: news@crdgw1.crd.ge.com Reply-To: volpe@underdog.crd.ge.com (Christopher R Volpe) Lines: 47 In article <2020@engage.enet.dec.com>, wallace@ynotme.enet.dec.com (Ray Wallace) writes: |> |>In article <0093BF08.7F3834E0@rigel.efd.lth.se>, e89hse@rigel.efd.lth.se |>writes... |>> I had a lot of trouble with a bug yesterday. The code was similar to the |>>following: |> |>>And it didn't work. Why? The answer is that the parameter f is a |>>double, not a float since all floats are converted to double when they are |>>passed as arguments to functions. Therefore &f is a ptr to double rather than a |>>ptr to float as one would expect looking at the declartion. |> |>Sounds like a compiler bug to me. Floats are promoted to double in a procedure |>call but since your procedure declared the parameter as a float the compiler |>should have "demoted" the parameter so that &variable would work properly. Doesn't sound like a compiler bug to me. The compiler should have "demoted" the parameter?!?!?! Huh?!?!?!? Is this some kind of crazy VAXism????? Where's it being demoted? By the caller? How would it know that it needs to demote it without a new style prototype in scope? By the callee, then?? How does it know what's being passed? There's no such thing as demoting parameters. |> |>FYI: Your code fragment worked properly with the VAX VMS-C compiler. Could be luck, based on compatible representations of float and double. But suppose on his machine, doubles have 2 more bits in the exponent? Passing a double to a function that expects a float will work about as well as passing an integer to a function that expects a float. |> |>--- |>Ray Wallace |> (INTERNET,UUCP) wallace@oldtmr.enet.dec.com |> (UUCP) ...!decwrl!oldtmr.enet!wallace |> (INTERNET) wallace%oldtmr.enet@decwrl.dec.com |>--- ================== Chris Volpe G.E. Corporate R&D volpecr@crd.ge.com