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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.3
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-03-08
             Status|UNCONFIRMED                 |ASSIGNED

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fix:

--- a/libstdc++-v3/include/bits/chrono_io.h
+++ b/libstdc++-v3/include/bits/chrono_io.h
@@ -2854,9 +2854,19 @@ namespace __detail
                basic_string<_CharT, _Traits, _Alloc>* __abbrev = nullptr,
                minutes* __offset = nullptr)
     {
-      sys_time<_Duration> __st;
-      if (chrono::from_stream(__is, __fmt, __st, __abbrev, __offset))
-       __tp = chrono::time_point_cast<_Duration>(utc_clock::from_sys(__st));
+      minutes __off{};
+      if (!__offset)
+       __offset = &__off;
+      using __format::_ChronoParts;
+      auto __need = _ChronoParts::_Year | _ChronoParts::_Month
+                   | _ChronoParts::_Day | _ChronoParts::_TimeOfDay;
+      __detail::_Parser_t<_Duration> __p(__need);
+      if (__p(__is, __fmt, __abbrev, __offset))
+       {
+         auto __ut = utc_clock::from_sys(__p._M_sys_days) + __p._M_time
+                       - *__offset;
+         __tp = chrono::time_point_cast<_Duration>(__ut);
+       }
       return __is;
     }

But we also need a change to the other from_stream overloads that are defined
in terms of utc_time, so that they don't allow 60s.

Reply via email to