http://llvm.org/bugs/show_bug.cgi?id=14771

             Bug #: 14771
           Summary: c++11: Fibonacci numbers calculations cause infinite
                    loop
           Product: clang
           Version: 3.2
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified


I play with c++11. And such code cause 100% cpu usage during 1 hour,
after that I just press ctrl+c.

#include <cstdio>

constexpr unsigned int fib(unsigned int N)
{
    return N <= 1 ? 1 : (fib(N - 1) + fib(N - 2));
}

template <unsigned int N>
struct Fib {
    enum { value = fib(N) };
};

int main()
{
    printf("%u\n", Fib<1000>::value);
}

I run clang in such way:
clang++ -fconstexpr-depth=10000 -Wall -std=c++0x test8.cpp

PS
time g++ -fconstexpr-depth=10000 -Wall -std=c++0x test8.cpp

real    0m0.108s
user    0m0.080s
sys     0m0.010s

So > 1 hour of work seems strange.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to