This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/50087] [C++0x] Weird optimization anomaly with constexpr
- From: "jason at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 16 Aug 2011 21:38:01 +0000
- Subject: [Bug c++/50087] [C++0x] Weird optimization anomaly with constexpr
- Auto-submitted: auto-generated
- References: <bug-50087-4@http.gcc.gnu.org/bugzilla/>
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.