Tcl Source Code

View Ticket
Login
Ticket UUID: 1203787
Title: NaN's escape detection in expressions
Type: Bug Created on: 2005-05-17 18:13:50
Submitter: dgp Assigned to: msofer
Subsystem: 47. Bytecode Compiler Severity:
Priority: 5 Medium Last modified: 2006-10-14 09:20:08
Status: Closed Closed by: sf-robot
Resolution: None Closed on: 2006-10-14 02:20:08
Version: obsolete: 8.4.9
Description:
% 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.
User Comments:
dgp added on 2005-08-27 03:15:24:
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

dgp added on 2005-08-27 03:28:08:
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.

dgp added on 2005-10-14 00:45:56:
Logged In: YES 
user_id=80530

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

still buggy in 8.4.11

msofer added on 2006-09-30 08:12:25:
Logged In: YES 
user_id=148712

worth fixing in 8.4?

sf-robot added on 2006-10-14 09:20:08:
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).