<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 from pseudodestructor with decltype(auto)"
   href="https://bugs.llvm.org/show_bug.cgi?id=48383">48383</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Segfault from pseudodestructor with decltype(auto)
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>ndkrempel@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following ill-formed code causes a segfault rather than an error:

  int main(int argc, char **argv) {
    argc.~decltype(auto);
  }

Reproduced on clang 3.3 up to clang 11.0.0 and trunk (with no particular flags,
or -std=c++anything, doesn't matter).

(An even more ill-formed one-liner like "_=0 .~decltype(auto)" will repro too.)

e.g. on trunk (<a href="https://gcc.godbolt.org/z/hnqzad">https://gcc.godbolt.org/z/hnqzad</a>):

Stack dump:
0.      Program arguments: /opt/compiler-explorer/clang-trunk/bin/clang++ -g -o
./output.s -mllvm --x86-asm-syntax=intel -S
--gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics
-fno-crash-diagnostics <source>
1.      <source>:2:25: current parser token ';'
2.      <source>:1:33: parsing function body 'main'
3.      <source>:1:33: in compound statement ('{}')
 #0 0x000055a3ed98846c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2e1a46c)
 #1 0x000055a3ed986204 llvm::sys::RunSignalHandlers()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2e18204)
 #2 0x000055a3ed986495 llvm::sys::CleanupOnSignal(unsigned long)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2e18495)
 #3 0x000055a3ed8f5068 CrashRecoverySignalHandler(int)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2d87068)
 #4 0x00007f7b12dec3c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #5 0x000055a3f030e6a8 (anonymous
namespace)::StmtProfiler::VisitOMPExecutableDirective(clang::OMPExecutableDirective
const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x57a06a8)
 #6 0x000055a3f030ddb6 clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous
namespace)::StmtProfiler, void>::Visit(clang::Stmt const*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x579fdb6)
 #7 0x000055a3f031133b clang::Stmt::Profile(llvm::FoldingSetNodeID&,
clang::ASTContext const&, bool) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x57a333b)
 #8 0x000055a3effee5c1 clang::ASTContext::getDecltypeType(clang::Expr*,
clang::QualType) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x54805c1)
 #9 0x000055a3efe43976 clang::Sema::BuildDecltypeType(clang::Expr*,
clang::SourceLocation, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52d5976)
#10 0x000055a3efab9a3f clang::Sema::ActOnPseudoDestructorExpr(clang::Scope*,
clang::Expr*, clang::SourceLocation, clang::tok::TokenKind,
clang::SourceLocation, clang::DeclSpec const&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4f4ba3f)
#11 0x000055a3ef6cf05b clang::Parser::ParseCXXPseudoDestructor(clang::Expr*,
clang::SourceLocation, clang::tok::TokenKind, clang::CXXScopeSpec&,
clang::OpaquePtr<clang::QualType>)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4b6105b)
#12 0x000055a3ef6c272b
clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*,
true>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4b5472b)
#13 0x000055a3ef6bcb6f
clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&,
clang::Parser::TypeCastState, bool, bool*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4b4eb6f)
#14 0x000055a3ef6bf536
clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool,
clang::Parser::TypeCastState, bool, bool*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4b51536)
#15 0x000055a3ef6c0cd4
clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4b52cd4)
#16 0x000055a3ef6c1979
clang::Parser::ParseExpression(clang::Parser::TypeCastState)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4b53979)
#17 0x000055a3ef71a45d
clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4bac45d)
#18 0x000055a3ef7177cb
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4ba97cb)
#19 0x000055a3ef718539
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4baa539)
#20 0x000055a3ef71eb79 clang::Parser::ParseCompoundStatementBody(bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4bb0b79)
#21 0x000055a3ef722353 clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4bb4353)
#22 0x000055a3ef676ba7
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4b08ba7)
#23 0x000055a3ef692c15 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4b24c15)
#24 0x000055a3ef671bd1
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4b03bd1)
#25 0x000055a3ef672301
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.250)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4b04301)
#26 0x000055a3ef6782a9
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4b0a2a9)
#27 0x000055a3ef679831
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4b0b831)
#28 0x000055a3ef679e85
clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4b0be85)
#29 0x000055a3ef66c963 clang::ParseAST(clang::Sema&, bool, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4afe963)
#30 0x000055a3ee1a6101 clang::FrontendAction::Execute()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3638101)
#31 0x000055a3ee15c49b
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x35ee49b)
#32 0x000055a3ee26db5b
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x36ffb5b)
#33 0x000055a3eba80fac cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xf12fac)
#34 0x000055a3eba7d68d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0xf0f68d)
#35 0x000055a3ee028195 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)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x34ba195)
#36 0x000055a3ed8f5143
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2d87143)
#37 0x000055a3ee028cc7
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 (.part.172)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x34bacc7)
#38 0x000055a3ee0019da
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x34939da)
#39 0x000055a3ee00252f
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+++0x349452f)
#40 0x000055a3ee00b3e5
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x349d3e5)
#41 0x000055a3eb9ad4a6 main
(/opt/compiler-explorer/clang-trunk/bin/clang+++0xe3f4a6)
#42 0x00007f7b1289d0b3 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x270b3)
#43 0x000055a3eba7d20a _start
(/opt/compiler-explorer/clang-trunk/bin/clang+++0xf0f20a)
clang-12: 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>