I'm using MinGW compiler 4.7.1 (Even tried 4.8.1) and am getting a strange error,,, for Release Versions only when  I use the this compiler flag Optimize even more (for speed) [-02].

It's always a fatal error, but only when this option in ticked in my Code::Blocks IDE.  Actually, any Optimization flags [-02], [-01], or [-0], I get this problem.

The error seems to be SIGSEGV, segmentation fault but I the code is definitely correct and runs fine when I don't use this flag.  

Is there a common reason why this is causing a problem?  What would the reason be?

Thanks