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

            Bug ID: 125369
           Summary: chrono::parse does not set failbit for unmatched %z
           Product: gcc
           Version: 16.1.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          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 <iostream>
#include <sstream>

int main()
{
  using namespace std::chrono;

  sys_seconds tp;
  std::string abbrev;
  minutes offset{};
  std::istringstream is{"2019-06-04T08:10:37Z"};
  from_stream(is, "%FT%T%z", tp, &abbrev, &offset);
  std::cout
    << (is.fail() ? "FAIL" : "OK")
    << " tp=" << tp
    << " offset=" << offset << "\n";
}

This prints:

OK tp=2019-06-04 19:10:37 offset=-660min

but "Z" should not be parsed as -1100 zone offset.

Reply via email to