#3140 NaN's escape detection in expressions

obsolete: 8.4.9
closed
miguel sofer
5
2006-10-14
2005-05-17
Don Porter
No

% binary scan [binary format d NaN] d d
1
% expr {$d}
domain error: argument not in valid range

Good. But...

% expr {$d && $d}
1

Problem is that TEBC directly pokes
into the objPtr->typePtr of values and
accepts anything of tclDoubleType as
a valid double. A call to Tcl_GetDoubleFromObj
would include the NaN check.

Discussion

  • Don Porter
    Don Porter
    2005-08-26

    Logged In: YES
    user_id=80530

    The #undef ACCEPT_NAN
    configuration on numerics branch
    has one fix:

    % binary scan [binary format d NaN] d d
    1
    % expr {$d}
    domain error: argument not in valid range
    % expr {$d && $d}
    floating point value is Not a Number

     
  • Don Porter
    Don Porter
    2005-08-26

    Logged In: YES
    user_id=80530

    Just FYI, the #define ACCEPT_NAN
    configuration isn't much different:

    % binary scan [binary format d NaN] d d
    1
    % expr {$d}
    NaN
    % expr {$d && $d}
    floating point value is Not a Number

    To do the shortcut evaluation
    of && we have to get an actual
    boolean value, so NaN can't
    be accepted as logical operands.

     
  • Don Porter
    Don Porter
    2005-10-13

    Logged In: YES
    user_id=80530

    this was fixed on the HEAD
    by the TIP 237 merge.

    still buggy in 8.4.11

     
  • miguel sofer
    miguel sofer
    2006-09-30

    • status: open --> pending
     
  • miguel sofer
    miguel sofer
    2006-09-30

    Logged In: YES
    user_id=148712

    worth fixing in 8.4?

     
  • Logged In: YES
    user_id=1312539

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 14 days (the time period specified by
    the administrator of this Tracker).

     
    • status: pending --> closed