public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/114240] New: sys_days not being parsed with only a date in the stream
@ 2024-03-05 15:11 howard.hinnant at gmail dot com
  2024-03-05 15:21 ` [Bug libstdc++/114240] " redi at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: howard.hinnant at gmail dot com @ 2024-03-05 15:11 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114240
           Summary: sys_days not being parsed with only a date in the
                    stream
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: howard.hinnant at gmail dot com
  Target Milestone: ---

#include <chrono>
#include <iostream>
#include <sstream>

int main(int argc, char**argv){

    std::istringstream ssStart{"2024-01-01"};
    std::istringstream ssEnd("2024-02-01");
    ssStart.exceptions(std::ios::failbit);

    std::chrono::sys_days tStart, tEnd;
    ssStart >> std::chrono::parse("%Y-%m-%d ", tStart);
    ssEnd >> std::chrono::parse("%Y-%m-%d ", tEnd);

    auto tDays = tEnd-tStart;
    std::cout << ssStart.str() << "," << ssEnd.str() << "," << tDays.count() <<
std::endl;
}

Expected output:

2024-01-01,2024-02-01,31

Actual output:

terminate called after throwing an instance of 'std::__ios_failure'
  what():  basic_ios::clear: iostream error

I expected this function: http://eel.is/c++draft/time.clock.system.nonmembers#6
to successfully parse the days-precision time_point because there is sufficient
information in the stream to form a valid date.

Demo: https://wandbox.org/permlink/FrtMteIddnb4ogpZ

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-03-09  0:33 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-05 15:11 [Bug libstdc++/114240] New: sys_days not being parsed with only a date in the stream howard.hinnant at gmail dot com
2024-03-05 15:21 ` [Bug libstdc++/114240] " redi at gcc dot gnu.org
2024-03-05 15:25 ` redi at gcc dot gnu.org
2024-03-05 15:31 ` howard.hinnant at gmail dot com
2024-03-05 15:53 ` redi at gcc dot gnu.org
2024-03-06 21:28 ` redi at gcc dot gnu.org
2024-03-07  0:10 ` redi at gcc dot gnu.org
2024-03-08 10:45 ` redi at gcc dot gnu.org
2024-03-09  0:29 ` cvs-commit at gcc dot gnu.org
2024-03-09  0:33 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).