<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 - invalid template destructor causes internal compiler error when using a complex data member"
   href="https://bugs.llvm.org/show_bug.cgi?id=51366">51366</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>invalid template destructor causes internal compiler error when using a complex data member
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

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

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

        <tr>
          <th>Reporter</th>
          <td>s.rohmen@gmx.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I just toyed with edge cases of the C++ standard and I know of course that this
is invalid code. But I stumbled into an ICE with this code
(<a href="https://godbolt.org/z/hz9eMn393">https://godbolt.org/z/hz9eMn393</a>):

#include <string>

class MyClass
{
public:
        MyClass()
        {}

        template<typename T>
        ~MyClass()
        {}

private:
        std::string m_str;
};

int main()
{
        MyClass foo;
        return 0;
}

The same issue does not happens when using simple types as int, double or a
custom struct. But I could reproduce it besides of std::string using
std::vector<int> and std::pair<int, int>.



Output:

<source>:10:2: error: destructor cannot be declared as a template
        ~MyClass()
        ^
PLEASE submit a bug report to <a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /opt/compiler-explorer/clang-trunk/bin/clang++ -g -o
/app/output.s -mllvm --x86-asm-syntax=intel -S
--gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics
-fno-crash-diagnostics <source>
1.      <source>:19:13: current parser token ';'
2.      <source>:18:1: parsing function body 'main'
3.      <source>:18:1: in compound statement ('{}')
 #0 0x000056051f7f9aef PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x000056051f7f79b0 llvm::sys::CleanupOnSignal(unsigned long)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x34f49b0)
 #2 0x000056051f748998 CrashRecoverySignalHandler(int)
CrashRecoveryContext.cpp:0:0
 #3 0x00007f012b5853c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #4 0x0000560521931f14
clang::Sema::MarkFunctionReferenced(clang::SourceLocation,
clang::FunctionDecl*, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x562ef14)
 #5 0x000056052189347f clang::Sema::FinalizeVarWithDestructor(clang::VarDecl*,
clang::RecordType const*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x559047f)
 #6 0x000056052181515b
clang::Sema::CheckCompleteVariableDeclaration(clang::VarDecl*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x551215b)
 #7 0x0000560521815ef0 clang::Sema::ActOnUninitializedDecl(clang::Decl*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5512ef0)
 #8 0x00005605215c9ff9
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52c6ff9)
 #9 0x00005605215db435 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52d8435)
#10 0x00005605215dc2e7
clang::Parser::ParseSimpleDeclaration(clang::DeclaratorContext,
clang::SourceLocation&, clang::ParsedAttributesWithRange&, bool,
clang::Parser::ForRangeInit*, clang::SourceLocation*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52d92e7)
#11 0x00005605215dc662
clang::Parser::ParseDeclaration(clang::DeclaratorContext,
clang::SourceLocation&, clang::ParsedAttributesWithRange&,
clang::SourceLocation*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52d9662)
#12 0x000056052165b8a9
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*,
clang::ParsedAttributesWithRange&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x53588a9)
#13 0x000056052165c5cd
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x53595cd)
#14 0x0000560521657172 clang::Parser::ParseCompoundStatementBody(bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5354172)
#15 0x0000560521657fa3 clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5354fa3)
#16 0x00005605215b2384
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52af384)
#17 0x00005605215db381 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52d8381)
#18 0x00005605215ad419
clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52aa419)
#19 0x00005605215adb21
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.280) Parser.cpp:0:0
#20 0x00005605215b3a49
clang::Parser::ParseExternalDeclaration(clang::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52b0a49)
#21 0x00005605215b4e69
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52b1e69)
#22 0x00005605215a86c9 clang::ParseAST(clang::Sema&, bool, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52a56c9)
#23 0x000056052074f8e2 clang::CodeGenAction::ExecuteAction()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x444c8e2)
#24 0x00005605200fc521 clang::FrontendAction::Execute()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3df9521)
#25 0x000056052009a5b2
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3d975b2)
#26 0x00005605201c8913
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3ec5913)
#27 0x000056051d5889bc cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x12859bc)
#28 0x000056051d584b8d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
driver.cpp:0:0
#29 0x000056051ff456e5 void llvm::function_ref<void
()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
<span class="quote">>, std::__cxx11::basic_string<char, std::char_traits<char>,</span >
std::allocator<char> >*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#30 0x000056051f748f83
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3445f83)
#31 0x000056051ff4779e
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
<span class="quote">>, std::__cxx11::basic_string<char, std::char_traits<char>,</span >
std::allocator<char> >*, bool*) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c4479e)
#32 0x000056051ff1d1da
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c1a1da)
#33 0x000056051ff1dd2f
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c1ad2f)
#34 0x000056051ff27115
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c24115)
#35 0x000056051d49dc3e main
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x119ac3e)
#36 0x00007f012b0350b3 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x270b3)
#37 0x000056051d58470a _start
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x128170a)
clang-14: error: clang frontend command failed with exit code 139 (use -v to
see invocation)
Compiler returned: 139</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>