[PATCH 0/5] libstdc++: chrono tzdb correctness fixes
Jonathan Wakely
jwakely@redhat.com
Wed Apr 15 14:11:56 GMT 2026
On Wed, 15 Apr 2026 at 14:39, David Malcolm <dmalcolm@redhat.com> wrote:
>
> On Mon, 2026-04-13 at 15:23 +0100, Jonathan Wakely wrote:
> > On Sat, 11 Apr 2026 at 14:33, Alvaro Begue <alvaro.begue@gmail.com>
> > wrote:
> > >
> > > This series fixes five distinct correctness issues in libstdc++'s
> > > <chrono> tzdb implementation that cause time-zone conversions to
> > > disagree with zic.c / libc localtime_r for specific real-world
> > > zones.
> >
> > This is really great, thanks. Some of the smaller patches might be
> > possible to merge now for GCC 16 but the larger ones will have to
> > wait
> > for GCC 17 (and then maybe get backported later for GCC 16.2).
> >
> > For all significant patches to GCC we require either copyright
> > assignment to the FSF or a DCO sign-off, please see
> > https://gcc.gnu.org/contribute.html#legal and let us know which route
> > you want to take.
> >
> >
> > >
> > > The motivation was a brute-force comparison harness that walks
> > > every
> > > IANA zone hourly across 1850-2150 (~563k transition samples) and
> > > compares chrono::time_zone::to_local() against libc's
> > > localtime_r().
>
> Out of curiosity:
> * is this test harness something you wrote that you can share? (with
> some kind of FLOSS license)
> * how long does it take to run?
I have a similar program (attached to this mail) that compares the
output of std::chrono to the output of
https://github.com/HowardHinnant/date (which uses the same TZif files
as glibc uses).
You need to link it with Howard's library, which is libdate-tz.so in
the date-devel RPM on Fedora.
Sample output:
$ ./compare PRC 1899 55
# 1899-01-01 00:00:00 -37342080 1899-01-01 00:00:00 -37342080
sys_info::first:
end: 1900-12-31 15:54:17 != 1901-01-01 00:00:00
# 1901-01-02 00:00:00 -36289440 1901-01-02 00:00:00 -36289440
sys_info::first:
begin: 1900-12-31 15:54:17 != 1901-01-01 00:00:00
# 1949-05-01 00:00:00 -10872000 1949-05-01 00:00:00 -10872000
sys_info::second:
end: 1949-05-27 15:00:00 != 1949-05-28 00:00:00
# 1949-05-01 16:00:00 -10871040 1949-05-01 16:00:00 -10871040
sys_info::first:
end: 1949-05-27 15:00:00 != 1949-05-28 00:00:00
# 1949-05-29 00:00:00 -10831680 1949-05-29 00:00:00 -10831680
sys_info::first:
begin: 1949-05-27 15:00:00 != 1949-05-28 00:00:00
You can run it in a loop for every time zone like so:
timedatectl list-timezones | while read tz ; do echo $tz ; ./compare
$tz 1700 350 ; done
This takes 3.5 minutes on my laptop.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: compare.cc
Type: text/x-c++src
Size: 3293 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20260415/f9cbc64b/attachment.bin>
More information about the Libstdc++
mailing list