[Bug c++/126764] New: Substring, std permutations and stoi(), strange error

"jori.mantysalo at tuni dot fi via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126764

            Bug ID: 126764
           Summary: Substring, std permutations and stoi(), strange error
           Product: gcc
           Version: 15.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jori.mantysalo at tuni dot fi
  Target Milestone: ---

In my computer this stucks on string 2147503689. Also tested on g++ version
14.3.0, same result.

#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string s = "1234567890";
    do {
      cout << s   << endl;
      stoi(s.substr(0, 10));
    }
    while (std::next_permutation(s.begin(), s.end()));
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.