Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 379a0543469f01667881dedbb5ba7d3734223bda
Ticket: d0f7ba56f0e8f93b7efb5b09ebc30a824bdd577a
INST_EQ first-argument NaN shortcut is too aggressive
User & Date: aspect on 2017-01-28 03:12:33
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. comment changed to:
    In the TIP#451 discussion on tcl-core it was shown that NaN is != to all strings, when provided as the first argument to ==/!=/>/</>=/<=.
    
    The cause seems to be that case INST_EQ in tclExecute.c shortcuts too quickly when type1 == TCL_NUMBER_NAN.  It should check that value2Ptr can be coerced to a number first.
    
    % set x "nan"
    % set y "gran"
    % expr {$x > $y} ;# expect 1
    0
    % expr {$x < $y} ;# expect 0
    0
    % expr {$y > $x} ;# expect 0
    0
    % expr {$y < $x} ;# expect 1
    1
    
    This is contrary to expr(n) "when all arguments to the operator allow numeric interpretations".
    
    Fixing this should probably consider the [pyk-emptystring] branch, which touches the same place to speed up a common case of comparison with "".
    
  5. foundin changed to: "8.5+"
  6. is_private changed to: "0"
  7. login: "aspect"
  8. priority changed to: "5 Medium"
  9. resolution changed to: "None"
  10. severity changed to: "Important"
  11. status changed to: "Open"
  12. submitter changed to: "aspect"
  13. subsystem changed to: "48. Number Handling"
  14. title changed to:
    INST_EQ first-argument NaN shortcut is too aggressive
    
  15. type changed to: "Bug"