Why would one ever want to compile with -O2 instead of -O3

We usually compile with -O2 because -O3 would "trigger subtle bugs".

For our GCC version -O3 enables more aggressive inlining which would actually reveal bugs otherwise unnoticed (e.g. use of uninitialized values from functions taking them as reference arguments or out-of-bounds access for arrays). It seems to me this aggressive inlining also allows a more expressive way of coding with smaller functions and -funswitch-loops helps keeping variable definitions more local in loops.

Given that bugs in our code are orders of magnitude more likely than compiler bugs and that we use -Wall -Wextra without any issues what kind of bugs should we be looking for?

If it matters we use gcc-4.3.2. Compile time is not a major issue for us.

16
задан Benjamin Bannier 12 April 2011 в 15:35
поделиться