Skip to content
Tcl Source Code Artifact [129332b760]
Login

Artifact [129332b760]

Artifact 129332b7601e93e96df5c5c67368910ffc5e1817f63c307ba12be0bb48d4ca17:

Ticket change [129332b760] - New ticket [00655c867eabd57a|00655c867e] <i>ClockGetdatefieldsObjCmd(): avoid signed integer overflow and platform-dependent behavior</i>. by chrstphrchvz on 2023-05-09 21:05:40.
D 2023-05-09T21:05:40.721
J assignee nobody
J closer nobody
J cmimetype text/x-fossil-wiki
J comment clock-61.3\striggers\san\s<tt>-fsanitize=signed-integer-overflow</tt>\serror:\r\n<pre>\r\ngeneric/tclClock.c:472:52:\sruntime\serror:\ssigned\sinteger\soverflow:\s9223372036854775807\s+\s210866803200\scannot\sbe\srepresented\sin\stype\s'long\slong'\r\n</pre>\r\n\r\nSee\sattached\spatch.\sTo\savoid\sthe\soverflow,\sI\ssuggest\sdividing\sby\s<tt>SECONDS_PER_DAY</tt>\sfirst\sand\sthen\sadding\s<tt>JULIAN_DAY_POSIX_EPOCH</tt>\sinstead.\sThe\squotient\salso\sneeds\sto\sbe\sconsistently\srounded\sdown,\srather\struncated\stowards\s0\s(GNU\sC\sand\sC99)\sor\showever\sa\sparticular\splatform\schooses\s(C89);\sotherwise\sincorrect\sresults\sare\sproduced\sfor\stime\svalues\sprior\sto\sthe\sPOSIX\sepoch.\sNot\srounding\sdown\salready\sproduces\sincorrect\sresults\sfor\stime\svalues\sprior\sto\sJulian\sday\s0;\sthe\sproposed\sclock-7.10\stest\scurrently\sfails\swith\s\r\n<pre>-210866803200\s-210866889600\s-1\s-210866803201\s0\s-210866803200\s0\s0\s0</pre>\r\n\swhen\sinteger\sdivision\struncates\stoward\s0.
J foundin core-8-6-branch
J is_private 0
J login chrstphrchvz
J priority 5\sMedium
J private_contact 6133eb3026f9b10aa9b7b48da92ae2834fc225b0
J resolution None
J severity Minor
J status Open
J submitter chrstphrchvz
J subsystem 16.\sCommands\sA-H
J title ClockGetdatefieldsObjCmd():\savoid\ssigned\sinteger\soverflow\sand\splatform-dependent\sbehavior
J type Patch
K 00655c867eabd57ac3acd93bffe2f93799c12c89
U chrstphrchvz
Z 4bef674e4339758f6aa021df8111728a