public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/42462]  New: wrong-code with computed-goto
@ 2009-12-22 13:31 wouter dot vermaelen at scarlet dot be
  2009-12-22 14:16 ` [Bug tree-optimization/42462] " paolo dot carlini at oracle dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: wouter dot vermaelen at scarlet dot be @ 2009-12-22 13:31 UTC (permalink / raw)
  To: gcc-bugs

> 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


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2010-02-08 14:11 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-22 13:31 [Bug tree-optimization/42462] New: wrong-code with computed-goto wouter dot vermaelen at scarlet dot be
2009-12-22 14:16 ` [Bug tree-optimization/42462] " paolo dot carlini at oracle dot com
2009-12-23 17:21 ` wouter dot vermaelen at scarlet dot be
2009-12-31 15:57 ` [Bug tree-optimization/42462] [4.5 Regression] " rguenth at gcc dot gnu dot org
2010-01-02 16:08 ` rguenth at gcc dot gnu dot org
2010-01-05 13:39 ` jamborm at gcc dot gnu dot org
2010-01-05 16:03 ` jamborm at gcc dot gnu dot org
2010-01-05 19:43 ` jamborm at gcc dot gnu dot org
2010-01-05 19:44 ` jamborm at gcc dot gnu dot org
2010-01-07 22:24 ` hjl at gcc dot gnu dot org
2010-02-08 14:11 ` rguenth at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).