From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4E7E53858D20; Tue, 5 Mar 2024 15:11:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4E7E53858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1709651506; bh=z87hBW9tCa/Sw9eJkRlAQb9HohOZXFSvnyFD4fGGngw=; h=From:To:Subject:Date:From; b=GqbeyfljbNeaty+NNxQ6eLk1XJ2XJSAw27+1mzk8Ee8CbMVrQvmhWu0gb9d601zBR kQJIr70zVoXZkX3On4NzVl2fS72jgfWWCOTX9wOmyHjn19xfXu5IVZYKjug8FB6woq qycoHRzxlqjfHwvg6zdeYvMz7mdtcdmS7d4mA9H8= From: "howard.hinnant at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/114240] New: sys_days not being parsed with only a date in the stream Date: Tue, 05 Mar 2024 15:11:45 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: howard.hinnant at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114240 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 #include #include 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 =3D 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.nonmembe= rs#6 to successfully parse the days-precision time_point because there is suffic= ient information in the stream to form a valid date. Demo: https://wandbox.org/permlink/FrtMteIddnb4ogpZ=