Path: utzoo!utgpu!watserv1!watmath!att!pacbell!pacbell.com!mips!apple!usc!snorkelwacker!paperboy!meissner From: meissner@osf.org (Michael Meissner) Newsgroups: comp.lang.c Subject: Re: Nasty bug Message-ID: Date: 31 Aug 90 14:32:38 GMT References: <2020@engage.enet.dec.com> <6441@wolfen.cc.uow.oz> Sender: news@OSF.ORG Organization: Open Software Foundation Lines: 39 In-reply-to: pejn@wolfen.cc.uow.oz's message of 31 Aug 90 02:56:00 GMT In article <6441@wolfen.cc.uow.oz> pejn@wolfen.cc.uow.oz (Paul Nulsen) writes: | wallace@ynotme.enet.dec.com (Ray Wallace) writes: | | >In article <0093BF08.7F3834E0@rigel.efd.lth.se>, e89hse@rigel.efd.lth.se | >writes... | >>... 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. | | I am not sure what the standard says, but this is definitely not a compiler | bug. With old K&R style declarations the compiler does not know the type of | a function argument until it sees the function definition. The function can | be invoked before the definition is known, and hence before the argument | types are known. In the case of floating point numbers, to avoid the | problems this creates the approach adopted was to promote all floating point | types to the common type of double. With ANSI style declarations this is no | longer necessary. I would still argue it's a compiler bug, even in K&R-I. If you said float, what the compiler should do is realize that a double was passed, take said double, convert it to float, and store it somewhere (including back on the stack where it was passed). Then any references are still float, and not double. You do have a conversion from double to float in the procedure prologue. The same conversion goes for char and short parameters, though you can usually fake the address (and using the little endian false belief, you don't have to do that). The one good thing you could say about IBM floating point format, is that the float and double formats were the same, and you could ignore the bottom bits. ANSI requires the above behavior in the absence of prototypes. -- Michael Meissner email: meissner@osf.org phone: 617-621-8861 Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142 Do apple growers tell their kids money doesn't grow on bushes?