Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

std::stoi causes buffer overflow with latest Intel C++ Compiler Classic

Eirik
Novice
689 Views

Hi,

I have been using std::stoi without problems for a long time but after upgrading to the latest compiler it crashes because of a buffer overflow in std::stoi("") when compiling with /GS (Buffer Security Check).

#include <string>

int main()
{
  try {
    std::stoi("");
  } catch (...) {
    return 1;
  }
}

 Compiling with Version 2021.7.1:

$> "C:\Program Files (x86)/Intel/oneAPI/compiler/2022.2.1/windows/bin/intel64/icl.exe" a.cpp /GS /EHsc
...
$> a.exe
$> echo %ErrorLevel%
-1073740791  # Apparently means stack buffer overflow

 Compiling with version 2021.6.0:

$> "C:\Program Files (x86)/Intel/oneAPI/compiler/2022.1.0/windows/bin/intel64/icl.exe" a.cpp /GS /EHsc
...
$> a.exe
$> echo %ErrorLevel%
1  # As expected

I have also tested with oneApi, MSVC, GCC and Clang which all works as expected.

I realize that this compiler is deprecated and will probably not get too much attention at the moment...

 

0 Kudos
1 Solution
Eirik
Novice
617 Views

This issue seems to have been solved in "C++ Compiler Classic 2021.8" (oneAPI 2023.0)!

View solution in original post

0 Kudos
1 Reply
Eirik
Novice
618 Views

This issue seems to have been solved in "C++ Compiler Classic 2021.8" (oneAPI 2023.0)!

0 Kudos
Reply