-C Address\svarious\sharmless\scompiler\swarnings\sfrom\n[forum:/forumpost/d526da8ee4|forum\spost\sd526da8ee4].
-D 2023-06-16T14:39:21.991
+C In\sdate/time\sfunctions,\sfix\sthe\srendering\sof\s"subsecond"\sand\sthe\ncomputeHMS()\sroutine\sto\sbetter\sdeal\swith\sfloating\spoint\nrounding\serrors\sthat\sarise\son\ssome\s32-bit\ssystems.
+D 2023-06-17T15:22:00.451
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490
F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e
F src/ctime.c 20507cc0b0a6c19cd882fcd0eaeda32ae6a4229fb4b024cfdf3183043d9b703d
-F src/date.c 36dfd2525c5544dbb246084e93839b839366e2204e7fb4a1a68a50f4344d32bc
+F src/date.c 62e7936bc31a6a78ad93d36e5261c41113a4c1cad7f043c77790a5ffc8c63e2d
F src/dbpage.c f3eea5f7ec47e09ee7da40f42b25092ecbe961fc59566b8e5f705f34335b2387
F src/dbstat.c ec92074baa61d883de58c945162d9e666c13cd7cf3a23bc38b4d1c4d0b2c2bef
F src/delete.c 092d745aa08969204a351711193e7f34de449ea57755eacbd11f1c316e9f7673
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P da1252b29852191eccbea98e0314408c75bb83a51f9d68d589705d4971a23850
-R bd866507ab2ad9c1d16b6b41135b6999
+P 365caf2f97e8f15842f52536e8d05d359e9d6e863182e020ce14a9a9f27ee057
+R 73503eeccae824219370676594eff77d
U drh
-Z 3cd810c8278f3d496fd739b853fdc856
+Z bc326b4113337a90f4cbc022d068432e
# Remove this line to create a well-formed Fossil manifest.
p->validYMD = 1;
}
-/* GCC (and sometimes Clang too) will sometimes be off by 1 millisecond
-** in computeHMS() on 32-bit platforms with optimization enabled.
-** I don't know if this is a compiler bug or a bug in the code. It is hard
-** to debug because with optimization enabled, gdb skips around so much
-** you cannot see what is happening, and if you try adding debug printf()s
-** to the code, the problem goes away.
-**
-** For now, I will work around the problem by disabling optimizations in
-** the computeHMS() routine.
-**
-** Problem seen using gcc-5.4.0, gcc-9.4.0, clang-10. Works ok on
-** MSVC, clang-3.4, and clang-6.0.
-**
-** Whatever the problem is, it causes some answers to be off by one
-** millisecond. So we get results like "2021-03-05 03:04:05.599" instead
-** of the desired result of "2021-03-05 03:04:05.600".
-**
-** To reproduce the problem using TH3:
-**
-** ./th3make debug.rc -O1 -m32 cfg/c1.cfg cov1/date8.test
-*/
-#if SQLITE_PTRSIZE==4 && GCC_VERSION>0
-#pragma GCC push_options
-#pragma GCC optimize ("O0")
-#endif
-
/*
** Compute the Hour, Minute, and Seconds from the julian day number.
*/
static void computeHMS(DateTime *p){
- int s;
+ int day_ms, day_min; /* milliseconds, minutes into the day */
if( p->validHMS ) return;
computeJD(p);
- s = (int)((p->iJD + 43200000) % 86400000);
- p->s = s/1000.0;
- s = (int)p->s;
- p->s -= s;
- p->h = s/3600;
- s -= p->h*3600;
- p->m = s/60;
- p->s += s - p->m*60;
+ day_ms = (int)((p->iJD + 43200000) % 86400000);
+ p->s = (day_ms % 60000)/1000.0;
+ day_min = day_ms/60000;
+ p->m = day_min % 60;
+ p->h = day_min / 60;
p->rawS = 0;
p->validHMS = 1;
}
-/* Reactivate GCC optimization */
-#if SQLITE_PTRSIZE==4 && GCC_VERSION>0
-#pragma GCC pop_options
-#endif
-
/*
** Compute both YMD and HMS
*/
zBuf[16] = '0' + (x.m)%10;
zBuf[17] = ':';
if( x.useSubsec ){
- s = (int)1000.0*x.s;
+ s = (int)(1000.0*x.s + 0.5);
zBuf[18] = '0' + (s/10000)%10;
zBuf[19] = '0' + (s/1000)%10;
zBuf[20] = '.';
zBuf[4] = '0' + (x.m)%10;
zBuf[5] = ':';
if( x.useSubsec ){
- s = (int)1000.0*x.s;
+ s = (int)(1000.0*x.s + 0.5);
zBuf[6] = '0' + (s/10000)%10;
zBuf[7] = '0' + (s/1000)%10;
zBuf[8] = '.';