https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123147
Bug ID: 123147
Summary: std::chrono::parse does not support wchar_t
Product: gcc
Version: 14.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: gast128 at hotmail dot com
Target Milestone: ---
Hello all,
not 100% sure if it's a bug or not. If we use std::chrono::parse with char it
compiles fine but if we use it with wchar_t it gives an error. msvc accepts the
code.
Example:
#include <chrono>
#include <sstream>
using ChronoLocalTime = std::chrono::local_time<std::chrono::microseconds>;
void From(const std::wstring& crstr)
{
ChronoLocalTime tpLoc;
std::wistringstream isstr{crstr};
isstr >> std::chrono::parse(L"%FT%T%z", tpLoc); // error
}
void From(const std::string& crstr)
{
ChronoLocalTime tpLoc;
std::istringstream isstr{crstr};
isstr >> std::chrono::parse("%FT%T%z", tpLoc); // ok
}
int main()
{
return 0;
}
Compile with -std=c++20. In compiler explorer error with 14.2 as 15.2. Error
seems to be chrono_io.h:3844:62: error: conversion from 'basic_string<wchar_t>'
to non-scalar type'. string __str = std::move(__buf).str();