Skip to content
Tcl Source Code History Of Ticket f894a85b9a4412d7
Login

History Of Ticket f894a85b9a4412d7

Artifacts Associated With Ticket f894a85b9a4412d7

  1. Ticket change [9fcc566164] (rid 261624) by serhiy.storchaka on 2026-11-14 08:05:35:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-markdown"
    4. comment initialized 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`.
      
    5. foundin initialized to: "9.0.5, 9.1.1"
    6. is_private initialized to: "0"
    7. login: "serhiy.storchaka"
    8. priority initialized to: "5 Medium"
    9. resolution initialized to: "None"
    10. severity initialized to: "Important"
    11. status initialized to: "Open"
    12. submitter initialized to: "serhiy.storchaka"
    13. subsystem initialized to: "06. Time Measurement"
    14. title initialized to:
      Free-form clock scan silently wraps numbers that do not fit into an int (regression in 9.0)
      
    15. type initialized to: "Bug"
  2. Ticket change [93a795aab6] (rid 261637) by serhiy.storchaka on 2026-11-14 09:29:03:

    1. icomment:
      Proposed fix in branch [clock-freescan-int-range](/timeline?r=clock-freescan-int-range). Numbers that do not fit into an int are rejected instead of truncated, and relative counts are calculated in 64 bits. The branch also fixes the following bugs.
      
      Relative months and years before the common era go in the wrong direction (base 101-03-15 B.C.E., `-gmt 1`):
      
      | Input | 8.6.18 and 9.0 | Branch |
      |---|---|---|
      | `clock scan "1 year"` | 102-03-15 B.C.E. | 100-03-15 B.C.E. |
      | `clock scan "13 months"` | 102-04-15 B.C.E. | 100-04-15 B.C.E. |
      | `clock scan "next Feb"` | 102-02-15 B.C.E. | 100-02-15 B.C.E. |
      | `clock add $base 1 year` | 102-03-15 B.C.E. | 100-03-15 B.C.E. |
      
      Signed integer overflows with `-valid 0` (`-base 0 -gmt 1`). The overflow is undefined behaviour; the 9.0 values are what gcc gives:
      
      | Input | 9.0 | Branch |
      |---|---|---|
      | `Dec 31 2147483647` (time 21474836:47) | 31450692 | 77340862020 |
      | `02/2147483647/2026` | -185540816332800 | 185544356918400 |
      | `14/02/2147483647` | 67675204942704000 | 67767976236297600 |
      
      Overflows in `clock add` (`-gmt 1`):
      
      | Input | 9.0 | Branch |
      |---|---|---|
      | `clock add 0 67553994410557440 hours` | 3386706919782612992 | integer value too large to represent |
      | `clock add 0 2147483647 weekdays` | -111325552329600 | 259759622044800 |
      | `clock add 0 2147483647 years` | -31536000 | integer value too large to represent |
      
      `clock add` now raises "integer value too large to represent" for a result outside the range of clock seconds, as it already does for such a base. Before, `clock add 0 67553994410557440 seconds 67553994410557440 seconds` returned 135107988821114880, which `clock format` does not accept.
      
    2. login: "serhiy.storchaka"
    3. mimetype: "text/x-markdown"
  3. Ticket change [ac2a39f092] (rid 261638) by jan.nijtmans on 2026-11-14 10:22:35:

    1. 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`.
      
    2. icomment: "+1, just go ahead!"
    3. login: "jan.nijtmans"
    4. mimetype: "text/x-fossil-wiki"
  4. Ticket change [441e0b7403] (rid 261649) by serhiy.storchaka on 2026-11-14 13:45:15:

    1. icomment:
      For 8.6: proposed fix in branch [clock-range-8-6](/timeline?r=clock-range-8-6). 8.6 has the B.C.E. bug in relative months and years, and wraps dates in `clock add` and the julian day helpers (`clock add 0 2147483647 years` gave 4455773-12-22 instead of the year 2147485617). Julian days beyond about ±5.8 million years now raise "integer value too large to represent". Numbers that do not fit into an int are already a syntax error in the 8.6 parser, and `clock format` of such seconds is unchanged.
      
    2. login: "serhiy.storchaka"
    3. mimetype: "text/x-markdown"
  5. Ticket change [3f628278dc] (rid 262079) by serhiy.storchaka on 2026-11-24 17:44:31:

    1. closedate changed to: "2461369.239250648301"
    2. closer changed to: "serhiy.storchaka"
    3. icomment:
      Merged into core-8-6-branch by Jan in [a0288fe887]. With [21bc2b48f7] (main) and [df2b525fbd] (core-9-0-branch), the fix is in all three branches.
      
    4. login: "serhiy.storchaka"
    5. mimetype: "text/x-fossil-wiki"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"