public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/111162] New: signed integer overflow triggered by std::chrono::parse
@ 2023-08-26 12:42 gcc at pauldreik dot se
  2023-08-26 13:52 ` [Bug libstdc++/111162] " redi at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: gcc at pauldreik dot se @ 2023-08-26 12:42 UTC (permalink / raw)
  To: gcc-bugs

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

            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 <chrono>
#include <format>
#include <sstream>
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 gets
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 represented in
type 'int'

link to reproducer (uses gcc trunk, may go stale quick):
https://godbolt.org/z/h617GT4EY

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

end of thread, other threads:[~2023-09-01 10:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-26 12:42 [Bug libstdc++/111162] New: signed integer overflow triggered by std::chrono::parse gcc at pauldreik dot se
2023-08-26 13:52 ` [Bug libstdc++/111162] " redi at gcc dot gnu.org
2023-08-29 12:10 ` redi at gcc dot gnu.org
2023-09-01 10:55 ` cvs-commit at gcc dot gnu.org
2023-09-01 10:57 ` 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).