This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.
chrono::parse
handle duplicated data?Section: 30.13 [time.parse] Status: New Submitter: Jonathan Wakely Opened: 2023-07-28 Last modified: 2023-11-03
Priority: 3
View other active issues in [time.parse].
View all other issues in [time.parse].
View all issues with New status.
Discussion:
A call to chrono::parse
can encounter redundant or contradictory
data, e.g.
or even simpler:stringstream("2023 2022") >> chrono::parse("%Y %C%y", yr);
These cases can both be successfully parsed, as the input stream contains the expected values in the expected format. But what value willstringstream("2023 2022") >> chrono::parse("%Y %Y", yr);
yr
have
after it returns?
[2023-11-02; Reflector poll]
Set priority to 3 after reflector poll.
"Should allow setting failbit
if an implementation does detect
inconsistent values."
"Yes, that's what MSVC does, so the wording needs something like:
it is unspecified whether setstate(ios_base::failbit)
is called on the basic_istream
or whether an unspecified value
is assigned to the p
argument."
Proposed resolution:
This wording is relative to N4950.
Modify 30.13 [time.parse] as indicated:
-17- If the
from_stream
overload fails to parse everything specified by the format string, or if insufficient information is parsed to specify a complete duration, time point, or calendrical data structure,setstate(ios_base::failbit)
is called on thebasic_istream
.-?- A format string can contain multiple flags that correspond to the same information, (e.g.,
"%Y %C%y"
or"%R %H:%M"
). If such a format string is successfully parsed but the extracted dates or times are not consistent, the value assigned to thetp
argument is unspecified.[Example:
The value ofchrono::year y; stringstream("1905 1915") >> parse("%Y %C%y", y);y
is unspecified;y.ok()
can befalse
. — end example]