gcc

Is it possible to bring GCC into an infinite loop?


Is it possible to bring GCC into an infinite loop by inputting strange source code? And if yes, how? Maybe one could do something with Template Metaprogramming?


Solution

  • Bugs are particularly transient, for example @Pestilence's answer was found in GCC 4.4.0 and fixed in 4.4.1. For a list of current ways to bring GCC to an infinite loop, check their Bugzilla.

    EDIT: I just found a new way, which also crashes Comeau. This is a more satisfying answer, for now. Of course, it should also be fixed soon.

    template< int n >
    struct a { 
        a< n+1 > operator->() { return a< n+1 >(); }
    };
    
    int main() {
        a<0>()->x;
    }