Andreas Bogk wrote:
Making a call here before knowing this is not sensible. In fact, I'm tempted to argue that it is generally a bad idea to do optimizations that lead to the same expression being evaluated to different results without making the user explicitly request them.
People always say this, but they don't really realize what they are saying. This would mean you could not put variables in registers, and would essentially totally disable optimization. The -O2 flag is exactly a request to do optimizations that may cause wrong programs to generate different results. Note by the way that formally safety-critical or security-critical software is very unlikely to be compiled at -O2 anyway.