| Ticket UUID: | 8afd93d3d360b933a8402157dccf4bb8a9c10026 | ||
| Title: | Clock format fails on NetBSD 11.1 on Sparc64 | ||
| Type: | Bug | Created on: | 2026-11-13 22:13:29 |
| Submitter: | anonymous | Assigned to: | jan.nijtmans |
| Subsystem: | 16. Commands A-H | Severity: | Severe |
| Priority: | 5 Medium | Last modified: | 2026-11-27 21:58:19 |
| Status: | Pending | Closed by: | nobody |
| Resolution: | Fixed | Closed on: | |
| Version: | 9.1.0 | ||
| Description: | ||||
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. | ||||
| User Comments: | ||||
jan.nijtmans added on 2026-11-13 23:03:40:
Does [2247d9b83c|this] help? serhiy.storchaka added on 2026-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.storchaka added on 2026-11-14 08:37:21:
I opened [f894a85b9a] for the range check and am working on it. jan.nijtmans added on 2026-11-27 21:58:19:
Merged to [537be3478b|trunk] | ||||
