SIGFPE C quiz answer

Doug Gwyn gwyn at brl-smoke.ARPA
Tue Apr 22 01:29:17 AEST 1986


> ...  Since "f" is not initialized, it may contain an illegal floating
> point number.  When the conversion is attempted, the system may very
> well say, "acckkk pffft!, I don't grok that value!!!," and send a
> signal.
> 
> I have seen this provoked on VAXen and on machines with National's 32xxx
> series floating fpoint co-processor.  Doug Gwyn suggests it can happen
> easily on PDP-11s as well.  You should consider it a bug everywhere.

Yes, doing anything with uninitialized data other than storing
a valid value in it should be considered an error.

However, the PDP-11 problem is more subtle.  Floating-point auto
variable reference can cause a trap to grow the stack, but with
some models of FP11 there is no way to recover from the fault.
The simplest fix is to have the compiler "touch" the lowest
stack location via TST (SP) immediately after allocating space
for the autos, so that the stack grows on a non-floating-point
reference.  Our PDP-11 C compiler does this under the same
circumstances that a reference to "fltused" is generated.



More information about the Comp.unix mailing list