[llvm-bugs] [Bug 26427] New: Template recursion can get error reporting into an infinite loop

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Feb 1 16:04:50 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=26427

            Bug ID: 26427
           Summary: Template recursion can get error reporting into an
                    infinite loop
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: r0maikx02b at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Error reporting can get into a very long (but probably not really infinite
loop).

The following snippet reproduces it nicely:

#include <memory>

template<class T>
void f(T t) {
   return f(std::make_unique<T>(t));
}

int main() {
    f(0);
}

I tried to compile it using: clang++ -std=c++14 main.cpp
The compiler starts spitting out long recursive template unique_ptr types.

Tested with r259432 but also happens in older versions as well.

Speculation:
If the make_unique call is replaced with an instantiation of a simpler template
class, then the built in recursion protection of clang kicks in, and it skips
the middle few hundred frames of the instantiation chain in the error message.
In any case you'll see that there is a very deeply nested type on the bottom of
the trace. My suspicion is that since unique_ptr has a more complicated
template interface, it simply takes much more characters to print a single
level of this nesting, and this causes the seemingly endless stream of errors.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160202/b72e626f/attachment.html>


More information about the llvm-bugs mailing list