Quote:
What is causing SIGSEGV error and why it is not shown by other compilers?
SIGSEGV is a runtime error saying that you try to access memory that you do not own.
Different compilers have different way to deal with memory allocation,
so depending on compiler choices, a wrong read/write outside of an array
will still be in your memory or not.
If M or N go up to 300, you will trash memory outside of array, resulting in potential wrong result.
One way to fix the problem is to add 1 to the size of array
int NEW[301][301];
It is OK with toy programs, but should be avoided as much as possible.