[llvm-bugs] [Bug 33762] New: Segfault due to stack overflow on infinite template instantiation depth
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Jul 12 08:50:43 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=33762
Bug ID: 33762
Summary: Segfault due to stack overflow on infinite template
instantiation depth
Product: clang
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: C++14
Assignee: unassignedclangbugs at nondot.org
Reporter: nicolasweber at gmx.de
CC: llvm-bugs at lists.llvm.org
Nicos-MacBook-Pro:llvm-build thakis$ cat test2.cpp
class ArrayBuffer;
template <typename T> class Trans_NS_WTF_RefPtr {
public:
ArrayBuffer *operator->() { return nullptr; }
};
Trans_NS_WTF_RefPtr<ArrayBuffer> get();
template <long> struct __visit_helper;
template <>
struct __visit_helper<0> {
template <typename _Visitor>
static constexpr void __visit(_Visitor __visitor) {
__visitor(get());
}
};
template <long _VariantIndex> struct __visit_helper2 {
template <typename _Visitor>
static constexpr void __visit(_Visitor __visitor) {
0 ? __visit_helper<_VariantIndex - 1>::__visit(__visitor)
: __visit(__visitor);
}
};
template <long _VariantIndex>
struct __visit_helper {
template <typename _Visitor>
static constexpr void __visit(_Visitor __visitor) {
__visit_helper2<_VariantIndex - 1>::__visit(__visitor);
}
};
template <typename _Visitor>
constexpr void visit(_Visitor __visitor) {
__visit_helper<1>::__visit(__visitor);
}
class ArrayBuffer {
char data() {
visit([](auto buffer) -> char { buffer->data(); });
}
};
Nicos-MacBook-Pro:llvm-build thakis$ bin/clang -std=c++14 -c test2.cpp
Stack dump:
0. Program arguments: /Users/thakis/src/llvm-build/bin/clang-3.5 -cc1
-triple x86_64-apple-macosx10.12.0 -Wdeprecated-objc-isa-usage
-Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free
-main-file-name test2.cpp -mrelocation-model pic -pic-level 2 -mthread-model
posix -mdisable-fp-elim -masm-verbose -munwind-tables
-faligned-alloc-unavailable -target-cpu penryn -target-linker-version 274.2
-dwarf-column-info -debugger-tuning=lldb -coverage-notes-file
/Users/thakis/src/llvm-build/test2.gcno -resource-dir
/Users/thakis/src/llvm-build/lib/clang/5.0.0 -stdlib=libc++ -std=c++14
-fdeprecated-macro -fdebug-compilation-dir /Users/thakis/src/llvm-build
-ferror-limit 19 -fmessage-length 256 -stack-protector 1 -fblocks
-fobjc-runtime=macosx-10.12.0 -fencode-extended-block-signature
-fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option
-fcolor-diagnostics -o test2.o -x c++ test2.cpp
1. test2.cpp:36:54: current parser token ')'
2. test2.cpp:34:1: parsing struct/union/class body 'ArrayBuffer'
3. test2.cpp:35:15: parsing function body 'ArrayBuffer::data'
4. test2.cpp:35:15: in compound statement ('{}')
5. test2.cpp:31:16: instantiating function definition 'visit<(lambda at
test2.cpp:36:11)>'
6. test2.cpp:26:25: instantiating function definition
'__visit_helper<1>::__visit<(lambda at test2.cpp:36:11)>'
7. test2.cpp:18:25: instantiating function definition
'__visit_helper2<0>::__visit<(lambda at test2.cpp:36:11)>'
8. test2.cpp:26:25: instantiating function definition
'__visit_helper<-1>::__visit<(lambda at test2.cpp:36:11)>'
...
855. test2.cpp:18:25: instantiating function definition
'__visit_helper2<-848>::__visit<(lambda at test2.cpp:36:11)>'
856. test2.cpp:26:25: instantiating function definition
'__visit_helper<-849>::__visit<(lambda at test2.cpp:36:11)>'
857. test2.cpp:18:25: instantiating function definition
'__visit_helper2<-850>::__visit<(lambda at test2.cpp:36:11)>'
clang-3.5: error: unable to execute command: Segmentation fault: 11
clang-3.5: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 5.0.0 (trunk 307659) (llvm/trunk 307660)
Found while reducing issue 33561.
--
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/20170712/14c99acb/attachment.html>
More information about the llvm-bugs
mailing list