Overview
| Artifact ID: | 9fcc566164375bf9d7ffd9b43241058c6514a6fc6542678914337334bdd80129 |
|---|---|
| Ticket: | f894a85b9a4412d77d4f3234e5a244b7b4d476a2
Free-form clock scan silently wraps numbers that do not fit into an int (regression in 9.0) |
| User & Date: | serhiy.storchaka on 2026-11-14 08:05:35 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-markdown"
- comment changed to:
Since the clock rewrite in Tcl 9.0 (TIP 688), the free-form parser of `clock scan` reads numbers as 64-bit integers, but stores them into the `int` fields of the date (hour, minutes, day, month, year, day ordinal). A number that does not fit into an int is truncated, and the result is often a valid value, so a wrong date is returned without error: | Input | 9.0.5 and 9.1.1 | 8.6.18 | |---|---|---| | `clock scan 12:4294967301:00` | 12:05:00 | syntax error | | `clock scan 4294967308:00:00` | 12:00:00 | syntax error | | `clock scan 4294967297/02/2026` | 2026-01-02 | syntax error | | `clock scan 02/4294967297/2026` | 2026-02-01 | syntax error | | `clock scan 02/03/4294969322` | 2026-02-03 | syntax error | | `clock scan "-4294967297 Monday"` | 1969-12-29 (a Monday) | syntax error | With Jan's fix for [8afd93d3d3], which makes `secondOfMin` an int, the seconds field would be affected too: `12:00:4294967301` would give 12:00:05. The year is the only field whose valid range (`-min-year`/`-max-year`) is the whole int range by default, so clamping alone cannot reject it. Relative months and years are wrapped too (with `-base 0 -gmt 1`): | Input | 9.0.5 and 9.1.1 | |---|---| | `clock scan "4294967297 months"` | 1970-02-01 (1 month) | | `clock scan "4294967297 years"` | 1971-01-01 (1 year) | | `clock scan "next 4294967297 Feb"` | 1970-02-01 | Relative days, weeks, fortnights and seconds are 64-bit and give the right result. 8.6.18 gives wrong results for all relative units with this number (the year 429502 for each of them) and a syntax error for `next 4294967297 Feb`.
- foundin changed to: "9.0.5, 9.1.1"
- is_private changed to: "0"
- login: "serhiy.storchaka"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- severity changed to: "Important"
- status changed to: "Open"
- submitter changed to: "serhiy.storchaka"
- subsystem changed to: "06. Time Measurement"
- title changed to:
Free-form clock scan silently wraps numbers that do not fit into an int (regression in 9.0)
- type changed to: "Bug"