That would be a way to go on Linux:
- Compile your program with debug info (
g++ -g merger_sort.cpp -o merger_sort
) - Load it in debuger:
>>> gdb merge_sort
- Run it:
(gdb) run
.
You will see:
Program received signal SIGSEGV, Segmentation fault.
0x0000000000400b1e in merge_sort (A=0x7ffffffddda0, p=0, r=1)
- look at the position in the code:
(gdb) layout src
- look at the backtrace:
(gdb) bt
It is pretty long… So you have a stack overflow:) USe debugger too see why.
solved I am getting segmentation fault for merge sort [closed]