In the project I’ve been coding recently, creating a new map inside a certain function and adding two elements to it causes a segmentation fault. These same lines (which are completely unrelated to the rest of the program), run completely fine in separate projects or online compilers, what could be the reason for the segmentation fault this time? how can lines that have nothing to do with the rest of the program run badly in this case?
these are the lines:
std::map<int, int> dict;
dict[2] = 1;
dict[1] = 2;
doing this runs just fine in an online compiler but doesn’t run well in my program, there’s no name overlapping, and I’ve checked that removing these lines makes the program run. I also tried using insert but I get the same error.
the segmentation fault is thrown in a line inside the c++ source code:
If you must know, this is inside a constructor of a class contained inside a .cpp file, it’s the only time map is used inside this function, the program runs if these lines are removed. Thank you in advance!