http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54021
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-07-19 07:12:18 UTC --- Perhaps the C++ FE could when parsing a constexpr function during finish_call_expr of __builtin_constant_p just temporarily force optimize = 1 if it is zero to prevent folding it to 0 (or alternatively, if it folds to 0, build it non-folded), it would be an extension over how this builtin behaves right now, on the other side as constexpr is "optimized" even at -O0 it would match the intent of the builtin. The question is if/when it will be actually folded to 0 afterwards if not in constexpr context.