I figured out the reason for segfault but I am still not sure why the behavior was different for different optimization flags. The reason for segfault was missing a variable in the list of private variables for the OMP parallel for directive.
Seg fault with -O0 or -O1 flag but not with -O2 or -O3
如需更全面地了解编译器优化,请参阅优化注意事项.



Seg fault with -O0 or -O1 flag but not with -O2 or -O3
I have a strange issue with an embarrasingly parallel code.When I run it with -O0 or -O1 optimization flags my code throws segfault. However, with -O2 or -O3 flag it runs just fine. The debugger (gdb) says the error is at a OpenMP parallel for directive. I would appreciate if someone has an idea as to what could be the possible reason. I am also debugging in the meantime and will post if I find something. Thank you.