Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 4a5125a413cb4ccaa3ba30845cb91037405c33cc
Ticket: 3105247fffffffffffffffffffffffffffffffff
-NaN?
User & Date: kennykb on 2010-12-22 23:13:41
Changes

  1. icomment:
    There are platforms - I no longer have my notes about which, I suspect HP PA-RISC - where even copying a signalling NaN either raises a signal (if the exception is unmasked) or silently converts it to a quiet NaN (if the exception is masked).  Even passing the NaN into Tcl_NewDoubleObj as a parameter is enough to trigger the behaviour. The patch as attached does nothing about that. It simply cannot. 
    
    What would really be needed for sNaN is a way to handle this right at the point of origin. That would involve either having Tcl_NewDoubleObj and friends accept a POINTER to the double (so it never needs to enter a register) and an interpreter pointer (for error message reporting). That would allow sNaN to be reported as an error before it ever enters a Tcl_Obj. (Of course, Tcl_GetDoubleFromObj would return an error for qNaN, but leave the NaN in place, just as it does now,) But - why bother? 
    
    Tcl's defined behavior should be that all NaNs are signalling when presented to [expr] or to Tcl_GetDoubleFromObj. The hardware-level sNaN is not a value in Tcl's value calculus. sNaN presented to Tcl_{New,Set}DoubleObj is quieted if the hardware settings are such that it can arrive there without a crash - recalling that in the arithmetic contexts of Tcl, it will continue to raise a Tcl-level exception. 
    
    I don't see a convincing reason for attempting to implement full-up IEEE exception control in Tcl proper, particularly in light of the fact that few C compilers can do anything sensible with FPE.  All that I wanted when I did this code originally was for C code to be able to call Tcl_NewDoubleObj without needing to jump through isnan() hoops to avoid crashing the process. I really don't see any use case for bit-for-bit preservation of sNaN, and I do foresee tremendous maintenance headaches if we start to allow it. sNaN crashes the process as soon as it leaks into the FPU, and maintenance changes on Tcl's floating-point pipeline are likely to introduce such leaks from time to time.
    
    
  2. login: "kennykb"
  3. mimetype: "text/plain"
  4. username: "kennykb"