Overview
| Artifact ID: | 5523d8e0300764efafe3e4b63c02ea87f28f712bc0f95d9d023fbd2d30fe74c0 |
|---|---|
| Ticket: | e3dcab1d14c0bcc5938ee570b2e0da208bff9239
Tcl aborts with wrong digits |
| User & Date: | anonymous on 2022-10-26 09:43:58 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-fossil-plain"
- comment changed to:
On Ubuntu 22.04 when running the following code, the application crashes with: wrong digit! Aborted (core dumped) #include <float.h> #include <limits.h> #include <stdlib.h> #include "tcl.h" Tcl_Interp *interp_ = NULL; const char *GetGlobalArray( const char *varname, const char *idx ) { const char *actval = Tcl_GetVar2( interp_, varname, idx, TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG ); if ( actval == NULL ) { fprintf( stderr, "Error in get %s (%s)\n", varname, idx ); exit( 1 ); } return actval; } void SetGlobalArray( const char *varname, const char *idx, double varval ) { fprintf( stderr, "Set %s, %s : %.*e\n", varname, idx, DBL_DIG, varval ); Tcl_Obj *ns1 = Tcl_NewStringObj( varname, -1 ); Tcl_IncrRefCount( ns1 ); Tcl_Obj *ns2 = Tcl_NewStringObj( idx, -1 ); Tcl_IncrRefCount( ns2 ); Tcl_Obj *nd = Tcl_NewDoubleObj( varval ); Tcl_IncrRefCount( nd ); double foo; Tcl_GetDoubleFromObj( interp_, nd, &foo ); fprintf( stderr, "Double value of object: %.*e\n", DBL_DIG, foo ); Tcl_Obj *actval = Tcl_ObjSetVar2( interp_, ns1, ns2, nd, TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG ); fprintf( stderr, "Content of array : %s\n", GetGlobalArray( varname, idx ) ); Tcl_DecrRefCount( ns1 ); Tcl_DecrRefCount( ns2 ); Tcl_DecrRefCount( nd ); } int main( int argc, const char *argv[] ) { Tcl_FindExecutable( argv[0] ); interp_ = Tcl_CreateInterp(); Tcl_ObjSetVar2( interp_, Tcl_NewStringObj( "tcl_precision", -1 ), NULL, Tcl_NewIntObj( 17 ), TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG ); double val = 6.4623485355705287e-27; SetGlobalArray( "some_array", "idx1", val ); return 0; } - foundin changed to: "8.6.12"
- is_private changed to: "0"
- login: "anonymous"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- severity changed to: "Severe"
- status changed to: "Open"
- submitter changed to: "anonymous"
- subsystem changed to: "10. Objects"
- title changed to: "Tcl aborts with wrong digits"
- type changed to: "Bug"