Issue with std::stol – ‘std::invalid_argument’ what(): stol

I have an issue with std::stol. All answers I have found regarding to issues with std::stol or std::stoi are dealing with C++11 compiling / building.

std::string myString;
long myLong = std::stol(myString);

When I use std::stol() I get the following error:

terminate called after throwing an instance of 'std::invalid_argument'
  what():  stol
Aborted (core dumped)

Any ideas? Building with gcc -std::C++11 works fine. Note: I think this is my first C++11 expression I use.

Leave a Comment