Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2001-04-17
05:39 • Ticket [218629ffff] Integer literal is converted to double status still Clos... artifact: ee658ff827 user: dgp
2000-10-26
08:26 • Closed ticket [218629ffff]. artifact: 8d6aa7f1b0 user: welch
01:03 • New ticket [218629ffff]. artifact: 30ee656dc1 user: nobody

Integer literal is converted to double

Closed / Fixed218629ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 01:03:20
OriginalBugID: 1516 Bug
Version: 8.1b2
SubmitDate: '1999-03-18'
LastModified: '1999-03-25'
Severity: CRIT
Status: Released
Submitter: pat
ChangedBy: stanton
RelatedBugIDs: 1606
OS: Other
OSVersion: FreeBSD 2.2.7
Machine: NA
FixedDate: '1999-03-24'
FixedInVersion: 8.1b3
ClosedDate: '2000-10-25'


Name:

Mark Diekhans



CVS:

updated mar 16, 1999, ~18:00 PST



Extensions:

TclX



ReproducibleScript:

    The enclosed script runs a subset of the TclX tests that reproduces

    the problem.  Use the trunk of the TclX tree and build with 8.1b2.

    cd to tcl/tests and place the enclosed script there.  Do a:

    

       ../unix/runtest bug.tcl

    

    There are two ways to reproduce it, controlled by editing an `if'

    command;

    A simple case that produces the failure ones and a complex case that

    causes

    it to happen several times.

    

    By turning on cmdtrace, it appears that the error always comes from

    the unknown handler.  In order to handle the TclX library format, the

    auto_load_index is replaced with a slightly modified version.  It

    appears

    that this has something to do with redefining a proc.

    

    In 8.1b1, I spent a some time trying to isolate this and got far enough

    to

    be convinced that is was a problem in Tcl core, not some bogus thing

    TclX

    was doing.

    

    # This causes errorInfo to be printed on test failure.

    set TEST_ERROR_INFO 1

    

    # This will product a trace of all executed commands.

    #cmdtrace on [open cmd.log w]

    

    proc runtest f {

        if [catch {uplevel #0 source $f} msg] {

            puts stderr "$f failed: $msg"

            puts stderr $::errorInfo

        }

    }

    

    if {1} {

        # This block causes several integer literals to be 

        # converted to doubles.

        runtest showproc.test

        runtest signal.test

        runtest socket.test

        runtest string.test

        runtest stringfil.test

        runtest sync.test

        runtest tcllib.test

    } else {

        # This block causes a single integer literal to be

        # converted to a double.

        runtest signal.test

        runtest tcllib.test

    }

    

    







ObservedBehavior:

    The code:

        for {set i [expr {[llength $auto_path] - 1}]} {$i >= 0} {incr i -1}

    {

    set dir [lindex $auto_path $i]

    

    ends up lindex-ing with a double value (1.0, 2.0, etc).  As I recall,

    this

    is because a Tcl_GetDoubleFromObj appears to convert the literal `1' in

    the

    expr to a double.

    

    







This needs to be verified and fixed.  03/23/1999 19:11 - surles -


03/24/1999 18:12 - stanton -

The simplest test case is:


proc foo {} {

    set x 1

    format %f $x

    expr {$x + 2}}

}

foo


Returns "3.0" instead of "3".


The problem is that the expression code relies on the type of the internal rep

to decide how to format the result instead of checking to see if the inputs really

look like integers.
welch Closed ticket [218629ffff]. [History diff]2000-10-26 08:26:08
dgp Ticket [218629ffff]: 3 changes [History diff]2001-04-17 05:39:25
Log in (anonymous is fine) to add a comment.