Skip to content
Tcl Source Code View Ticket
Login

View Ticket

"0x" handled as float constant

Closed / Fixed648441ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 24 years ago
Descriptionplain2002-12-04 15:32:58
Version 8.4.1 of Tcl, at least on linux, regards the
string "0x" as a floating point constant:

%string is double 0x
1
% set tcl_patchLevel
8.4.1

In windows the behaviour is different:
%string is double 0x
0
% set tcl_patchLevel
8.4.0

Notice I've checked it with different versions of Tcl
in the two platforms, although I believe 8.4.1 in windows
behaves correctly.

Juan Carlos---
dgpplain2002-12-05 06:34:35
Logged In: YES 
user_id=80530

In the original report on CLT, Juan Carlos reported
a difference between Tcl 8.3 and Tcl 8.4 on:

expr 0x

That is a different issue than the one in the
submitted report.  This report just reflects the
difference in the strtod() implementations of
two different C libraries.  glibc on Linux is
C99 compiant, and the C library on Windows
apparently is not.

For the [expr 0x] incompatibility, I suspect
a new parser bug.
ooxplain2002-12-05 16:48:11
Logged In: YES 
user_id=662619

You surely know (much) better than me, but I guess both
problems are either a single one or at least deeple related.

I've been running [expr 0x] as part of the automated regression
testing of a package I maintain from the last four years or so, 
both in windows and linux, throughout Tcl versions from 8.0, 
and "0x" has never been handled as float until 8.4.0 in linux.

So there's never been any version between platforms not Tcl
versions. Now both differences arise, and at the same time.

You said "0x" being a fallback floating point constant is genuine
C99 behaviour. You also say glibc on Linux is C99 compliant.
From how long ago? The strtod(3) man page of the various
linux systems I have handy say: "A hexadecimal number 
consists of a ``0x'' or ``0X'' fol­lowed by a nonempty sequence 
of hexadecimal digits  possi­bly 2...". Notice the nonempty.

Juan Carlos---
dgpplain2002-12-12 00:53:54
Logged In: YES 
user_id=80530

My point is that on my Linux box I see:

% info patch
8.2.3
% string is double 0x
1

So this report mentions a platform difference,
not a Tcl version difference.

OTOH, the behavior of [expr 0x] did change
between 8.3 and 8.4.  They are different
problems.
dgpplain2002-12-12 01:53:38
Logged In: YES 
user_id=80530

TclParseInteger("0x",2) is returning 0 instead of 1.

That appears to be the root cause.  testing futher....
dgpplain2002-12-12 03:30:00
Logged In: YES 
user_id=80530

Yes, that's it.  Committing fix and new test.
dgp Closed ticket [648441ffff]. [History diff]2002-12-12 03:30:42
dgpplain2002-12-12 23:46:10
Logged In: YES 
user_id=80530

For more info on the C99 issue,
see Tcl Bug 523537.
ooxplain2002-12-13 00:04:13
Logged In: YES 
user_id=662619

Thanks for the C99 info!

Juan Carlos---
Log in (anonymous is fine) to add a comment.