Bug converting unsigned to double in BSD 4.[23]

throopw at dg_rtp.UUCP throopw at dg_rtp.UUCP
Sun Nov 23 06:39:41 AEST 1986


> woods at hao.UUCP (Greg Woods)
>   I've seen something similar, and I think your bug probably has to do with
> the same thing. On a VAX, and every machine I've worked on EXCEPT the ISI-68K,
> the first 32 bits of a double form a float.

The two problems are very likely unrelated, except in a most tenuous
sense.  The original bug in the ((double)~(unsigned)1) was a either a
problem in implementing the conversion from type unsigned to double, or
a problem in deciding what type a twiddle of an unsigned type was.  The
nature of the error (integer max becomes -1) made it very likely that
the original problem was an integer format problem, not a floating point
format problem.

> This is a BUG, and it has bitten us
> badly in many big libraries where we have little stubs designed to allow
> the calling of FORTRAN routines from C without having to observe FORTRAN
> calling conventions,

It is not clear that this is a bug under K&R semantics.  I think it
likely that ANSI would consider this a bug, since they already mandated
that taking the address of a character formal would "work right".  In
essence, it means that the compiler would be obliged to copy the
declared-float-but-really-double formal argument into an invisible float
local variable when the address of the formal is taken.

--
There was a radical defect somewhere, and I must search it out and cure it.
                                --- Mark Twain
-- 
Wayne Throop      <the-known-world>!mcnc!rti-sel!dg_rtp!throopw



More information about the Comp.lang.c mailing list