Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2019-12-16
10:09
Better fix for [3390638]: making the intVal variable unsigned prevents the need for using sprintf() ... check-in: c164ea07e7 user: jan.nijtmans tags: core-8-5-branch
2011-09-14
03:05 • Closed ticket [3390638fff]: Tcl f8.5.10 fails sparc solaris 10 with native cc</i... artifact: 49307455ac user: dgp
02:29 • Ticket [3390638fff]: 4 changes artifact: 876afe17e7 user: dgp
2011-08-12
23:17 • Ticket [3390638fff]: 4 changes artifact: e2f0c9b9db user: wkechel
23:14 • Ticket [3390638fff]: 1 change artifact: 806a4153c9 user: wkechel
23:09 • Ticket [3390638fff]: 1 change artifact: 51c96e69c1 user: wkechel
16:09 • New ticket [3390638fff]. artifact: 87d0f1be3c user: wkechel

Tcl f8.5.10 fails sparc solaris 10 with native cc

Closed / Accepted3390638fffffffffffffffffffffffffffffffffCreated 15 years agoUpdated 15 years ago
Descriptionplain2011-08-12 16:09:03
Tcl fails when build with natice solaris studio cc under sparc solaris 10. Compiler optimzation breaks tclUtil.c:TclFormatInt.

Indicator: tests fail. Simple testcase 'format %d 0x80000000' -> -s OOPS??

The following patch solves the issue:

in tclUtils.c:TclFormatInt change the code after the comment

    /*
     * Check whether "n" is the maximum negative value. This is
     * -2^(m-1) for an m-bit word, and has no positive equivalent;
     * negating it produces the same value.
     */

old:
    if (n == -n) {
return sprintf(buffer, "%ld", n);
    }

NEW:
    intVal = -n;
    if (n == -n || intVal == n) {
return sprintf(buffer, "%ld", n);
    }

My Configuration (no gcc in path!):
ssol10% echo $path
/usr2/gnu/bin /usr2/scripts /usr/bin /sbin /usr/sbin /usr/ccs/bin /usr/bin/X11 /usr/bin /usr/openwin/bin /usr/dt/bin
ssol10% ../unix/configure --prefix=/usr2/gnu
wkechel Ticket [3390638fff]: 1 change [History diff]2011-08-12 23:09:51
wkechel Ticket [3390638fff]: 1 change [History diff]2011-08-12 23:14:54
wkechelplain2011-08-12 23:17:28
This code was not present in 8.5.9, sprintf was used directly. Why has this been modified and broken?
dgpplain2011-09-14 02:29:35
TclFormatInt() was brought back into Tcl 8.5
just as it is in Tcl 8.4.  The attempt to replace it
with a sprintf() call was too costly in performance
loss when used in Tcl applications that produce
large tables of printed numbers.  I assume Tcl 8.4
has the same problem on your platform?

FWIW, I cannot reproduce the problem on a local
Solaris 10 system building Tcl with "Forte Developer 7 C 5.4"

Nevertheless, if the patch works around your optimizer woes,
we might as well apply it.
dgpplain2011-09-14 03:05:22
allow_comments - 1

Patch accepted on all release branches.
Log in (anonymous is fine) to add a comment.