I compile the next code, and compile it succesfully:
#include <iostream>
#include <sstream>
using namespace std;
int main(int argc, char *argv[])
{
// cast the first parameter to int and assing to variable
int size_of_array ;
istringstream string_to_int(argv[1]);
string_to_int >> size_of_array;
std::pair<int, int> arr1[5021410];
cout << "arr1 declared." << endl;
std::pair<int, int> arr2[size_of_array];
cout << "arr2 declared." << endl;
return EXIT_SUCCESS;
}
I compile it with the next command:
g++ -o testing_error.bin testing_error.cpp -O3 -Wall -g
(testing_error.cpp
is the code showing above, obviously).
If I exec the script, but I get a segmentation fault erro:
$ ./testing_error.bin 5021410
arr1 declared.
[1] 10753 segmentation fault (core dumped) ./testing_error.bin 5021410
I'm not figure out where is my mistake. Any idea?