https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107285
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> --- That is just bogus expectation. __builtin_constant_p works that it has a cut-off after certain optimizations (for -O0 already very early), if optimizations before it manage to optimize the argument into a constant, it is true. After the cut-off the remaining occurrences are folded into false. So, if bar is inlined or say IPA constant propagated, the argument is constant, while if it isn't inlined nor IPA constant propagated (etc.), as seems to be the case for -Og, it is not constant, thus you get what you asked for. __builtin_constant_p better should be used as a way to optimize code without changing the observable behavior...