Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: f129bb06de39bec039e8884c001467a81420213a
Ticket: 452032ffffffffffffffffffffffffffffffffff
Some Strings Incorrectly Convrtd To Ints
User & Date: dtashley on 2001-08-17 12:27:44
Changes

  1. assignee changed to: "hobbs"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    Tcl 8.3.1 and later.
    
    Concise sample.
    
    % expr 400000000
    400000000
    % expr 4000000000
    -294967296
    % expr 40000000000
    integer value too large to represent
    
    The text above gives concise example of problem.  Here 
    is more from newsgroup posts.
    
    Please notify me by e-mail when you begin working on 
    this problem.  That way, if I begin work on it, it 
    won't be wasted effort (i.e. we should not have a 
    collision of effort).
    
    Dave Ashley ([email protected])
    --------------------------
    
    With Tcl 8.3.1 (but it may have been corrected by 
    now), Windows platform,
    static build, i.e. my compilation under Microsoft 
    Visual C++.
    
    I discovered that when I call the library function:
    
    Tcl_GetIntFromObj()
    
    there are some values of strings that are not 
    converted to integers
    correctly.
    
    Here are the examples:
    
    The string "-400000000" (there are eight zeros there) 
    is converted
    correctly.
    
    The string "-4000000000" (there are nine zeros there) 
    is converted to
    294967296, but TCL_OK is returned.
    
    The string "-40000000000" (there are ten zeros there) 
    causes TCL_ERROR to be
    returned.
    
    There is a window of positive and negative numbers 
    where the number is
    converted incorrectly to integer format, but TCL_OK is 
    returned.  The
    example with nine zeros is in this window.
    
    Another more simple way to show the bug is:
    % expr -400000000 * 1
    -400000000
    % expr -4000000000 * 1
    294967296
    % expr -40000000000 * 1
    integer value too large to represent
    % expr 400000000 * 1
    400000000
    % expr 4000000000 * 1
    -294967296
    % expr 40000000000 * 1
    integer value too large to represent
    %
    
    The bug is in the function.
    SetIntFromAny(interp, objPtr)
    
    
  4. foundin changed to: "None"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "dtashley"
  9. subsystem changed to: "11. Conversions from String"
  10. title changed to: "Some Strings Incorrectly Convrtd To Ints"
  11. type changed to: "Bug"