https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123165

--- Comment #1 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <[email protected]>:

https://gcc.gnu.org/g:e79f0f818c0e42d0d84c90a54684dfb269ac388c

commit r17-471-ge79f0f818c0e42d0d84c90a54684dfb269ac388c
Author: Jonathan Wakely <[email protected]>
Date:   Tue Apr 28 13:15:22 2026 +0100

    libstdc++: Improve handling of leap second expiry time [PR123165]

    This change allows the hardcoded list of leap seconds in <chrono> to be
    used even when the program is executing after the hardcoded expiry date
    in that header.

    For times after the hardcoded expiry, the inline __get_leap_second_info
    function calls a new library function which compares the number of
    hardcoded leap seconds in the header with the number of leap seconds
    defined in the tzdata leapseconds file (usually provided by the OS).

    There are three leap second lists that are relevant here. The first is
    the hardcoded list (and its expiry time) in the <chrono> header. That is
    fixed when the user code is compiled, and might be out of date by the
    time the application runs. The second list (and its expiry time) is
    hardcoded in tzdb.cc in the libstdc++.so library. If the application
    uses a newer libstdc++.so at runtime than the <chrono> header used at
    compile time, we can still avoid going to the filesystem for dates
    within the expiry time of the list in libstdc++.so. The third list is
    the most up-to-date one which is read from the leapseconds file.

    The code added by this commit tries to avoid reading the file when
    possible (because that's slower than using the in-memory lists), and if
    it does have to go to the file system, it tries to avoid doing so again
    next time the leap seconds are needed.

    libstdc++-v3/ChangeLog:

            PR libstdc++/123165
            * acinclude.m4 (libtool_VERSION): Bump version.
            * config/abi/pre/gnu.ver (GLIBCXX_3.4.36): Add new symbol
            version and export new symbol.
            * configure: Regenerate.
            * include/std/chrono (__detail::__recent_leap_second_info):
            Declare new function and make it a friend of varous classes.
            (leap_second): Make private constructor constexpr. Remove friend
            declaration for get_leap_second_info.
            (__detail::__get_leap_second_info): Use new function for times
            past the hardcoded expiry.
            * src/c++20/tzdb.cc (tzdb_list::_Node::fixed_leaps): Move array
            of leap seconds here from _S_read_leap_seconds.
            (fixed_expiry, num_leap_seconds): New globals.
            (__detail::__recent_leap_second_info): Define new function.
            (tzdb_list::_Node::_S_read_leap_seconds): Populate vector from
            _Node::fixed_leaps. Rename bool variable to clarify meaning.
            (tzdb_list::_Node::_S_replace_head): Update num_leap_seconds
            when updating the tzdb_list.
            * testsuite/util/testsuite_abi.cc: Update known_versions and
            latestp.
            * testsuite/std/time/clock/utc/leap_second_info-2.cc: New test.

    Co-authored-by: Tomasz KamiÅski <[email protected]>
    Signed-off-by: Tomasz KamiÅski <[email protected]>

Reply via email to