From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id ED2753858C2C; Sat, 26 Aug 2023 12:42:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ED2753858C2C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1693053733; bh=RaZBszZM4DlX/AFjhGQLAy1bmyWPEbwIOCaMOOi1C6I=; h=From:To:Subject:Date:From; b=Dc/taSIdlsvSJrNsgrttEC1gWPwHanZWU3nwNaugZti1fIRW1aOZOywLR0VGhSRgh Vit2t/5BKAx2P+ElRoZkwMxSTQ9OB1/i1mOzgmxox2rmgCqOeK0Wd10jwpIO+rxX7d jf6SjMFa5Nuq9mt1ugmSzHPTDep1CrVbmf7GkKjg= From: "gcc at pauldreik dot se" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/111162] New: signed integer overflow triggered by std::chrono::parse Date: Sat, 26 Aug 2023 12:42:13 +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: gcc at pauldreik dot se 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=3D111162 Bug ID: 111162 Summary: signed integer overflow triggered by std::chrono::parse Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: gcc at pauldreik dot se Target Milestone: --- The following program: #include #include #include int main() { std::istringstream is("21474837"); std::chrono::minutes x; is >> std::chrono::parse("%8C", x); } invokes undefined behaviour. If compiled with the current gcc trunk, one ge= ts this when executed: /opt/compiler-explorer/gcc-trunk-20230824/include/c++/14.0.0/bits/chrono_io= .h:3174:20: runtime error: signed integer overflow: 21474837 * 100 cannot be represente= d in type 'int' link to reproducer (uses gcc trunk, may go stale quick): https://godbolt.org/z/h617GT4EY=