<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Segfault due to stack overflow on infinite template instantiation depth"
   href="https://bugs.llvm.org/show_bug.cgi?id=33762">33762</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Segfault due to stack overflow on infinite template instantiation depth
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++14
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>nicolasweber@gmx.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>