Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Clock format fails on NetBSD 11.1 on Sparc64

Pending8afd93d3d360b933a8402157dccf4bb8a9c10026Created 19 days agoUpdated 5 days ago
Descriptionplain2026-11-13 22:13:29
Platform: NetBSD 11.1 running on a Sun Ultra 5 (Sparc64, big-endian).
Tcl is version 9.1.0.
GCC is version 12.5.0.

The issue:
clock format commands return zero for hours/minutes/seconds.

To reproduce:
$ clock format [clock seconds] -format "%a %b %d %H:%M:%S"
Expected result: Fri Nov 13 21:49:32
Actual result: Fri Nov 13 00:00:00

Many more clock functions appear to be affected as well, running 'make test' shows a very large number of errors in clock.test.

Testing on an amd64 platform shows no errors in clock.test, which suggests a big/little endian issue.

Looking at the source, secondOfDay is declared to be Tcl_WideInt in tclDate.h but is accessed using IntFieldAt() within tclClockFmt.c.
That will read incorrect data on a big-endian host.
Referenced by3
  • 537be3478bFix [8afd93d3d3]: Clock format fails on NetBSD 11.1 on Sparc64 check-in2026-11-27 21:55:02
  • ac2a39f092Ticket [f894a85b9a] Free-form clock scan silently wraps numbers that do not fit into an int (regression in 9.0) status still Open with 4 other changes ticket2026-11-14 10:22:35
  • 2247d9b83cFix [8afd93d3d3]: Clock format fails on NetBSD 11.1 on Sparc64 check-in2026-11-13 23:02:37
jan.nijtmanswiki2026-11-13 23:03:40

Does [this] help?

serhiy.storchakawiki2026-11-13 23:14:15

The two fields were int until [bbb77cc456] (the fix of an overflow in clock add, before TIP 688 was merged) widened them, but the format and scan tables still access them as int. They only hold a time of day, so the fix in [2247d9b83c] is right, and clock.test passes with it.

One side effect: the free-form parser stores its 64-bit numbers into these int fields before the range check, so clock scan "12:00:4294967301" now gives 12:00:05 instead of "invalid time". Hours and minutes already behave this way: "12:4294967301:00" gives 12:05:00. A range check in tclGetDate.y before the assignment would fix all three.

serhiy.storchakawiki2026-11-14 08:37:21

I opened [f894a85b9a] for the range check and am working on it.

jan.nijtmanswiki2026-11-27 21:58:19

Merged to [trunk]

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