> I have solved that problem. I just removed the gcc flag -O3 from my
> compile script and the error vanished. However the speed of my code is
> also reduced to 50 iterations/minute from 70 iterations/minute, still
> not bad.
> Is there any alternative to -O3 flag?
> I tried -O2 too but this also gives errors.
You could try to set optimizations more fine-grained. Every -Osomething
stands for a certain set of optimizations. Start with e.g. "gcc -Q -O2
--help=optimizers" to see all available optimizations and which are
enabled at -O2. Read about them on the gcc manpage. Disable those that
decrease accuracy. Enable more from the O3 level if you like. Be aware
that decreased accuracy is maybe the source of your described
performance gain. As your algorithm seems to be quite (numerically)
instable, an additional look into dokumentation regarding precision and
general sources regarding numerical instablity might benefit you while
estimating the effects of certain optimizations.