This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/42462] New: wrong-code with computed-goto
- From: "wouter dot vermaelen at scarlet dot be" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Dec 2009 13:31:01 -0000
- Subject: [Bug tree-optimization/42462] New: wrong-code with computed-goto
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
> cat Foo.cc
#define INLINE inline __attribute__((always_inline))
template<class> struct Foo {
inline bool isFalse() { return false; }
template <bool> void f1() {}
template <bool> INLINE void f2() { f1<false>(); }
template <bool> void f3() { f2<false>(); }
template <bool> INLINE void f4() { f3<false>(); }
void exec2();
void execute();
inline void unused();
};
template<class T> inline void Foo<T>::unused() {
f4<true>();
}
template<class T> void Foo<T>::exec2() {
static void* table[2] = { &&begin, &&end };
goto *(table[0]);
begin:
if (isFalse()) f1<false>();
end:
return;
}
template<class T> void Foo<T>::execute() {
while (true) { exec2(); }
}
template class Foo<int>;
int main() {
Foo<int> c;
c.execute();
}
> g++ -O2 Foo.cc
This program should get stuck in an infinite loop (I confirmed this with
g++-4.4 (Debian 4.4.2-3) 4.4.2). But when compiled with a recent SVN snapshot
it exits immediately.
I'm using revision trunk@155361 on linux x86_64.
--
Summary: wrong-code with computed-goto
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: wouter dot vermaelen at scarlet dot be
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42462