Whenever I get a
Segmentation Fault error, I know that somewhere I am accessing memory that "does not belong to me".
In some nonobvious cases, I have to rely on debugging tools such as a profiler (Valgrind for example).
Unfortunately, during runtime, I only get the following error message:
And nothing else. My questions are:
Why doesn't the program give more info about the error during runtime?
Can the compiler somewhat help find possible memory leaks?
Ps: This is not a question on why segmentation fault errors happen: I understand why.
No you can't, because segfaults are not reported by your program, but by your operating system receiving a trap at the CPU level (which is kind of an exception). At this point, the CPU deems your program unrecoverable and tells the operating system to stop it. Your program cannot do anything but shutdown, because the CPU gave that order.