I have the following test program:
#include <string>
int main(int argc, char* argv[]) {
try {
return std::stoi("3000127232");
}
catch (...) {
return 0;
}
}
When I compile this on ubuntu with C++11 and run the code I get a return value of 0. This is what I expect because the value in the string is out of range.
But when I compile it for a rasperry-buildroot 18.11 I can run the program on rasperry, but I get a segfault. This I don't expect.
Is there another solution to convert strings to ints (without segfaults when out of range), or does anyone have another idea?