Is there any reason why -O3 is not used or unable to be set?

In practice, I cannot see any reason why it would be explicitly disallowed (I haven’t used -O2 as far back as I can remember); it also discourages doing silly and minor optimizations in code.

I would say (after some googling), that it is because of historical reasons and maybe by intention to make life of C/C++ coders easier - as stated in one of the links:

It (-O3) does however tend to reveal cases where people rely on undefined behavior, due to relying more strictly on the rules, and especially corner cases, of the language(s).

SO1, SO2

Can you give a more concrete example of what exactly you are trying to do ?

Maybe some one have a clue here, there are clever people around :wink: While waiting, you can ask CodeChef team via e-mail ( and let as know when they reply (it may take some time).

1 Like

That is why I brought up having the option to do it vs. forced to do it. I understand that in some hypothetical cases it can cause errors, but from my experience this is pretty rare.

Here’s a concrete example for C99 since it may have been unclear:

gcc -Werror -pedantic-errors -std=c99 -O3 -fomit-frame-pointer -o prog prog.c