[Bug libstdc++/126543] New: 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

            Bug ID: 126543
           Summary: chrono::parse does not reject "60" seconds for a
                    non-leap second
           Product: gcc
           Version: 16.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

#include <chrono>
#include <sstream>
#include <assert.h>

int main()
{
  std::istringstream in;
  std::chrono::utc_seconds ut;
  std::chrono::sys_seconds st;

  in.str("2016-12-31 23:59:60");
  in >> parse("%F %T", ut);
  assert(in.good()); // is a leap second

  in.str("2016-12-31 23:59:60");
  in >> parse("%F %T", st);
  assert(in.fail()); // can't read leap seconds into sys_time
  in.clear();

  in.str("2016-12-31 23:58:60");
  in >> parse("%F %T", ut);
  assert(in.fail()); // not a leap second
  in.clear();
}

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.

"2016-12-31 23:59:60" is valid
"2016-12-31 23:58:60" is not (a leap second can only occur in the last second
of December or the last second of June).
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.