[LLVMbugs] [Bug 12053] New: infinite recursion in decltype crashes compiler
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Feb 21 11:01:05 PST 2012
http://llvm.org/bugs/show_bug.cgi?id=12053
Bug #: 12053
Summary: infinite recursion in decltype crashes compiler
Product: clang
Version: trunk
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P
Component: C++0x
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: seth.cantrell at gmail.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
Created attachment 8086
--> http://llvm.org/bugs/attachment.cgi?id=8086
source, preprocessed source, and build script
Attempting to instantiate the following template causes clang to segfault
template<typename T> auto foo(T t) -> decltype(foo(t)) {}
The printed error
clang: error: unable to execute command: Segmentation fault: 11
preprocessed source, and build script included, as per clang's instructions, as
well as the original source.
The command line I used was simply clang++ -std=c++11 main.cpp
A non-template version of the above does not cause a crash. It simply results
in a compile error because foo is not declared until the opening brace.
auto foo(int t) -> decltype(foo(t)) {}
Also, trying a non-recursive template shows that the name used inside the
decltype is not a dependent name, and so is resolved during the first phase of
two-phase lookup
//int bar(int i) { return 1; }
template<typename T>
auto foo(T t) -> decltype(bar(t))
{
return bar(t);
}
int bar(double d) { return 2; }
int main() {
foo(double());
}
If I understand correctly, in the case of the recursive template clang should
be trying to resolve 'foo' inside decltype during the first phase of two-phase
lookup, and this should fail, resulting in a substitution error with a nice
compiler diagnostic.
--
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.
More information about the llvm-bugs
mailing list