Silvio a Beccara wrote:
Thanks for your help and suggestion. I forgot to mention that my program is parallel, using MPI. The problem could be possibly connected with some buffer overrun in MPI. I have three consecutive MPI_Reduce instructions on three medium sized vectors (108 elements). If I take out one of these reductions, everything seems to work well even with -O3. Otherwise, it always crashes (I retried many times) with both -O2 and -O3, but with -O it seems to work fine. The whole program is rather big, but maybe I can cut out some routine that reproduces the crash and post it. As for using gdb, I tried it, but it seems to give different results, because it's only able to run on one processor.
I have little experience with parallel programs, and I don't know the MPI routines, so I think I can't help you much there.
Of course, if it's the compiled program that crashes, not the compiler, it might also be a problem in your code, such as memory corruption. In such cases, besides regular debugging, sometimes tools like efence (under libraries on the GPC page) might help.
Frank