https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124513
--- Comment #3 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:fbc5d2b1ab17ba7eb919f2c77f5788645c18006a commit r16-8169-gfbc5d2b1ab17ba7eb919f2c77f5788645c18006a Author: Jonathan Wakely <[email protected]> Date: Thu Mar 19 11:42:48 2026 +0000 libstdc++: Fix parsing of UNTIL times in tzdata.zi [PR124513] Zone lines ending with a plain number as the time for the DST transition (e.g. "2026 Mar 16 2") were incorrectly parsed as changing at midnight. The problem was that eofbit got set after extracting the "2" from the stream using `in >> i`, then the `in >> at.indicator` expression failed and set failbit, so that the `if (in >> at.indicator)` condition was always false and so the assignment to at.time guarded by that condition was never performed. So the at.time member was always left equal to zero, i.e. midnight. Suffixed times such as "2s" or "2u" were parsed correctly. This commit fixes the operator>> overload for the Indicator enum to not cause failbit to be set if eofbit is already set. This means that the `in >> at.indicator` expression yields true when converted to bool, and the assignment to at.time happens. Not trying to extract an Indicator when eofbit is already set is correct, because it's valid for there to be no indicator suffix on an AT time (that just means the time should be interpreted as wall time). There was also a bug in the handling of a "-" value for the time, which is supposed to mean midnight but was not being parsed due to failing to skip leading whitespace. That did no harm in most cases, because the "-" would not be extracted from the stream but would then cause a failure to parse an integer number of hours, and no time would be set, causing it to default to midnight, which is what "-" means anyway. However, a value of "-u" is supposed to mean midnight UTC and "-s" is supposed to mean midnight standard time, and the indicators for UTC or standard were not being set in those cases. This fix uses std::ws to skip initial whitespace, and then correctly handles "-" followed by EOF. libstdc++-v3/ChangeLog: PR libstdc++/124513 * src/c++20/tzdb.cc (operator>>(istream&, at_time::Indicator&)): Do not peek at the next character if eofbit is already set. (istream& operator>>(istream&, at_time&)): Skip whitespace before the first character. Handle EOF when parsing "-" as time. Do not peek for ":" or "." if eofbit already set. * testsuite/std/time/time_zone/116110.cc (test_apia): Remove offset of 24h now that the UNTIL time is parsed correctly. * testsuite/std/time/time_zone/124513.cc: New test. Reviewed-by: Tomasz KamiÅski <[email protected]>
