Nasty bug

Christopher R Volpe volpe at underdog.crd.ge.com
Fri Aug 31 04:17:11 AEST 1990


In article <2020 at engage.enet.dec.com>, wallace at ynotme.enet.dec.com (Ray
Wallace) writes:
|>
|>In article <0093BF08.7F3834E0 at rigel.efd.lth.se>, e89hse at 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 at oldtmr.enet.dec.com
|>		(UUCP)		...!decwrl!oldtmr.enet!wallace
|>		(INTERNET)	wallace%oldtmr.enet at decwrl.dec.com
|>---
                       
==================
Chris Volpe
G.E. Corporate R&D
volpecr at crd.ge.com



More information about the Comp.lang.c mailing list