GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
libstdc++ Performance Win

Improve libstdc++ handling of leap second expiry time

libstdc++ can now use its built-in leap second list even after the expiry date by consulting the OS tzdata, avoiding filesystem reads where possible.

The <chrono> header in libstdc++ has a hardcoded list of leap seconds, which can become outdated. This change allows the library to continue using this list even after its expiry date, by checking the system’s tzdata leapseconds file. The code prioritizes using in-memory lists to avoid slower filesystem reads, and caches the results.

In Details

The <chrono> header's leap second data expires. __get_leap_second_info now consults the OS's tzdata leapseconds file if the hardcoded expiry is reached. The code attempts to avoid reading the file when possible, and caches the results. The three leap second lists involved are the hardcoded list in <chrono>, the list in tzdb.cc (in libstdc++.so), and the system's leapseconds file.

For Context

The C++ <chrono> library provides time and date functionality, including handling of leap seconds. Because leap seconds are not known far in advance, the library must have a way to update its information. This change allows the C++ library to continue to work correctly even after its built-in leap second information expires, by consulting the operating system's time zone database. This ensures that time calculations remain accurate even as leap seconds are added.

Filed Under: libstdc++chronoleap secondstime zones