http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50087
Jason Merrill <jason at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |missed-optimization Status|UNCONFIRMED |NEW Last reconfirmed| |2011-08-16 Ever Confirmed|0 |1 --- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> 2011-08-16 21:38:01 UTC --- This is more or less expected behavior. Since a const variable declaration has different semantics depending on whether or not the initializer is a constant-expression, a compiler needs to find a constant value if there is one. So we do, and joe is initialized with that constant value. But in the second testcase, there is no semantic constraint on whether or not the call fib(92) is a constant-expression, so we don't try to reduce it to a constant, assuming that normal optimization can do just as well. But for whatever reason, in this case normal optimization isn't doing as well as constexpr evaluation can.