Skip to content
Tcl Source Code View Ticket
Login

View Ticket

NaN's escape detection in expressions

Closed1203787fffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 20 years ago
Descriptionplain2005-05-17 18:13:50
% 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.
dgpplain2005-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
dgpplain2005-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.
dgpplain2005-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
msoferplain2006-09-30 08:12:25
Logged In: YES 
user_id=148712

worth fixing in 8.4?
sf-robotplain2006-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).
Log in (anonymous is fine) to add a comment.