This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/50385] New: missed-optimization: jump to __builtin_unreachable() not removed
- From: "wouter.vermaelen at scarlet dot be" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 13 Sep 2011 15:04:27 +0000
- Subject: [Bug tree-optimization/50385] New: missed-optimization: jump to __builtin_unreachable() not removed
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50385
Bug #: 50385
Summary: missed-optimization: jump to __builtin_unreachable()
not removed
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: tree-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: wouter.vermaelen@scarlet.be
I'm not sure, but this issue might be the same as bug 49054 (if so, feel free
to delete this one).
#include <vector>
struct S { int a, b; };
std::vector<S> v;
int search_1(int a) {
for (auto it = v.begin(); /**/; ++it)
if (it->a == a) return it->b;
}
int search_2(int a) {
for (auto& e : v)
if (e.a == a) return e.b;
__builtin_unreachable();
}
I expected to see the same generated code for both functions. Instead the 2nd
one still contains some useless comparisons and jumps past the end of the
function. Since such a (conditional) jump is anyway undefined behavior it can
as well be removed (including the instructions required to calculate the
condition).
Tested with SVN revision 178775 (20110912) on Linux x86_64.