Tcl Source Code

View Ticket
Login
Ticket UUID: 1116542
Title: bogus [binary format d] output
Type: Bug Version: obsolete: 8.4.9
Submitter: dgp Created on: 2005-02-04 23:03:06
Subsystem: 12. ByteArray Object Assigned To: dkf
Priority: 8 Severity:
Status: Closed Last Modified: 2005-09-27 22:57:02
Resolution: Fixed Closed By: dgp
    Closed on: 2005-09-27 15:57:02
Description:
% info patch
8.4.9
% parray tcl_platform
tcl_platform(byteOrder) = littleEndian
tcl_platform(machine)   = alpha
tcl_platform(os)        = Linux
tcl_platform(osVersion) = 2.2.23
tcl_platform(platform)  = unix
tcl_platform(user)      = dgp
tcl_platform(wordSize)  = 8
% binary scan [binary format d 83] c* v; set v
0 0 0 0 0 0 0 0


It appears the [binary format d] spits
out all x00 bytes.

This is fixed in 8.5a3.  Can someone
who knows what happened backport
the fix please?
User Comments: dgp added on 2005-09-27 22:57:02:
Logged In: YES 
user_id=80530


tests fine.  thanks.

dkf added on 2005-09-27 22:46:05:
Logged In: YES 
user_id=79902

Fixed in 8.4 branch I believe (and I think the HEAD was
immune for unrelated reasons). Retest and reopen if the fix
fails please (it works for me)

dgp added on 2005-03-12 00:40:44:
Logged In: YES 
user_id=80530

not a Linux/Alpha bug so much as
brokenness of an ancient compiler.

not clear what could go in compat
to deal with this?

dkf added on 2005-02-28 16:12:50:
Logged In: YES 
user_id=79902

If there's a bug like this on linux-alpha, should there be
updates to configure to detect it and install a compat/
workaround in that case?

(Fix looks good BTW, but the test probably ought to use a
value that has an exact binary representation: 1.25 instead
of 1.2?)

dgp added on 2005-02-26 05:22:55:

File Added - 123099: 1116542.patch

Logged In: YES 
user_id=80530

Attached patch is a partial
backport from the HEAD that
corrects this problem.

dgp added on 2005-02-26 04:55:28:
Logged In: YES 
user_id=80530


This is apparently a problem
with memcpy() on this system.

Replacing "sizeof(double)" with
"1+sizeof(double)" makes things
work.  Leaving it as it is, only one
byte is copied by memcpy()
instead of the full 8 bytes of
the double  value.

hobbs added on 2005-02-26 02:29:24:
Logged In: YES 
user_id=72656

This works fine for me with AMD64/Linux, Sol8-64 and HP-UX
11 64-bit (pa-risc).

dgp added on 2005-02-26 02:19:28:
Logged In: YES 
user_id=80530


Bug was likely introduced
with this change:

9/15/97 (bug fix) Alignment problems in "binary format"
would cause a
crash on some platforms when formatting floating point
numbers. (SS)

dgp added on 2005-02-26 02:02:34:
Logged In: YES 
user_id=80530


Bug arrived in Tcl 8.0p1:

% info patch
8.0
% binary scan [binary format d 1.2] d w; set w
1.2

% info patch
8.0p1
% binary scan [binary format d 1.2] d w; set w
2.51973479379e-322

How can we not have tests in the
test suite that [binary scan] and 
[binary format] are inverse functions?

dgp added on 2005-02-26 01:41:28:
Logged In: YES 
user_id=80530

FWIW, this brokenness showed
up sometime between Tcl 8.0
and Tcl 8.0.3.  Still investigating...

dkf added on 2005-02-09 21:31:28:
Logged In: YES 
user_id=79902

What happened was TIP#129, but why that makes a difference I
really don't know.

Attachments: