[Bug libstdc++/126543] chrono::parse does not reject "60" seconds for a non-leap second

"redi at gcc dot gnu.org via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126543

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2026-07-31
             Status|UNCONFIRMED                 |NEW

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #0)
> The last assertion fails, because we allow ":60" for any utc_time, but we
> should verify that the parsed time really was a leap second.

Currently the first assertion also fails, but that's easier to fix:

-- a/libstdc++-v3/include/bits/chrono_io.h
+++ b/libstdc++-v3/include/bits/chrono_io.h
@@ -4778,7 +4778,7 @@ namespace __detail
                                       && !__is_floating)
                    {
                      auto __val = __read_unsigned(__num ? __num : 2);
-                     if (0 <= __val && __val <= 59) [[likely]]
+                     if (0 <= __val && __val <= 60) [[likely]]
                        __s = seconds(__val);
                      else
                        {

We already have code to check for seconds(60) later, causing us to set
_M_is_leap_second, and then that causes us to fail for sys_time, gps_time, and
tai_time.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.