Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: f726d1393daff0f0e41ef5289b56b5bea846e689
Ticket: 1090869fffffffffffffffffffffffffffffffff
Tcl_GetInt Returns Illegal Overlfow On AMD64
User & Date: sanjeev_singh on 2004-12-24 15:43:52
Changes

  1. assignee changed to: "msofer"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    Hi,
    I am running on Opteron ie Amd 64 bit mc. While porting 
    my 32 bit code I am running into this problem with 
    reading 32 bit numbers that have bit 31 set.
    
    Basically the code below fails if the user passed 
    0x8000000 as the arguments.
    
    int tb_test(ClientData dummy, Tcl_Interp *interp, int 
    argc, char **argv) 
    {
      int code = TCL_OK;  
      int value[2];
    
      Tcl_GetInt(interp, argv[1], &value[0]);
      Tcl_GetInt(interp, argv[2],  &value[1]);
    
      printf("VALUE0=0x%x\n", value[0]);
      printf("VALUE1=0x%x\n", value[1]);
    
      return code;
    }
    
    When run in tclsh this gives
    % myCmd 0x7fffffff 0x80000000
    VALUE0=0x7fffffff
    VALUE1=0x0
    integer value too large to represent
    % 
    
    The problem seems to be in file tclGet.c in the following 
    line-
     if ((errno == ERANGE) || (((long)(int) i) != i)) {
    
    It should be instead
     if ((errno == ERANGE) || (((long)(unsigned int) i) != i)) {
    
    -sanjeev
    
    
  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: "sanjeev_singh"
  9. subsystem changed to: "45. Parsing and Eval"
  10. title changed to: "Tcl_GetInt Returns Illegal Overlfow On AMD64"
  11. type changed to: "Bug"