[Bug libstdc++/124852] std::chrono::time_zone misparses Zone UNTIL fields whose DAY uses the ON format (lastSun, Sun>=8, etc.)
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Jul 31 10:56:16 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124852
--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Tomasz Kaminski
<tkaminsk@gcc.gnu.org>:
https://gcc.gnu.org/g:c7c4fa25e59db38994195bbe75341a7adc8987d7
commit r14-12777-gc7c4fa25e59db38994195bbe75341a7adc8987d7
Author: Álvaro Begué <alvaro.begue@gmail.com>
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 <jwakely@redhat.com>
Co-authored-by: Tomasz KamiÅski <tkaminsk@redhat.com>
Signed-off-by: Álvaro Begué <alvaro.begue@gmail.com>
Signed-off-by: Tomasz KamiÅski <tkaminsk@redhat.com>
(cherry picked from commit 2b5e55eea69acbc6e46fa3463164e62bcc436e0d)
More information about the Gcc-bugs
mailing list