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

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

https://gcc.gnu.org/g:2b5e55eea69acbc6e46fa3463164e62bcc436e0d

commit r17-486-g2b5e55eea69acbc6e46fa3463164e62bcc436e0d
Author: Álvaro Begué <[email protected]>
Date:   Tue May 12 14:55:01 2026 +0200

    libstdc++: Support ON-format DAY in Zone UNTIL field [PR124852]

    The Zone-line UNTIL parser only accepted a plain day-of-month integer
    for the DAY field, while the tzdata.zi grammar accepts the same ON-style
    forms as Rule lines: lastSun, Sun>=8, Sat<=20, etc. Real zones use these
    forms in their UNTIL DAY: Europe/Simferopol's `3 - MSK 1997 Mar lastSu
    1u`, for instance, became `Mar 1` (silently misparsed) instead of `Mar
    30`, leaving Simferopol an extra 29 days in MSK.

    The previous parser's `int d = 1; in >> m >> d >> t;` chain silently
    left d == 1 when the day token wasn't a digit, then went on to parse the
    remainder as the TIME field.

    Renames on_day to on_month_day, and factor out the day-component parser
    parser from operator>>(istream&, on_day&) as operator>> for newly added
    on_day_t tag type, and reuse it for the UNTIL DAY field. The operator
    handles all three on_day forms (DayOfMonth, LastWeekday, LessEq /
    GreaterEq).  The MONTH-only and YEAR-only short forms are still accepted
    because the DAY/TIME fields are optional and default to day 1, time 00:00.
    The on_day struct's pin() method handles the year/month-relative
    resolution.

    The DAY field is unambiguously distinguishable from a TIME field that
    could otherwise follow the MONTH directly: per zic's grammar, MONTH
    must be followed by DAY before any TIME is allowed.  So we always
    attempt to parse a DAY if any non-whitespace remains after the MONTH.

    libstdc++-v3/ChangeLog:

            PR libstdc++/124852
            * src/c++20/tzdb.cc (on_day): Rename to...
            (on_day_month): Rename from on_day.
            (on_day_month::on_day_t, on_day_month::on_day): Define.
            (operator>>(istream&, on_day_t&&)): Factored out of
            operator>>(istream&, on_day&).
            (operator>>(istream&, on_day&)): Use on_day_t parser.
            (operator>>(istream&, ZoneInfo&)): Replace the integer DAY
            parser with on_day_t for the UNTIL field.
            * testsuite/std/time/time_zone/until_day_on.cc: New test.

    Reviewed-by: Jonathan Wakely <[email protected]>
    Co-authored-by: Tomasz KamiÅski <[email protected]>
    Signed-off-by: Álvaro Begué <[email protected]>
    Signed-off-by: Tomasz KamiÅski <[email protected]>

Reply via email to