<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 - Parser accepts undeclared identifier in pseudodestructor expression, then crashes"
   href="https://bugs.llvm.org/show_bug.cgi?id=45294">45294</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Parser accepts undeclared identifier in pseudodestructor expression, then crashes
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </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>arthur.j.odwyer@gmail.com
          </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>Inspired by <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - Segfault from pseudodestructor with template alias"
   href="show_bug.cgi?id=45142">https://bugs.llvm.org/show_bug.cgi?id=45142</a> -- thanks @rsmith for
fixing that one yesterday! Apparently the whole area of pseudodestructor
parsing is troublesome...

    // <a href="https://godbolt.org/z/yCP_nn">https://godbolt.org/z/yCP_nn</a>
    int i = 1 . ~A<>();

This ICEs Clang (see stack trace below).
If you don't try to *use* the result of the bogus AST expression, e.g.

    void test() { 1 . ~A<>(); }

then Clang happily treats the nonsense as a no-op, which is also a bug.


Stack dump:
0.      Program arguments: /opt/compiler-explorer/clang-trunk/bin/clang++ -g -o
./output.s -S --gcc-toolchain=/opt/compiler-explorer/gcc-9.2.0
-fcolor-diagnostics -fno-crash-diagnostics <source> 
1.      <eof> parser at end of file
2.      <source>:1:5: LLVM IR generation of declaration 'i'
3.      <source>:1:5: Generating code for declaration 'i'
 #0 0x00005560c95616aa llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2ab16aa)
 #1 0x00005560c955f284 llvm::sys::RunSignalHandlers()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2aaf284)
 #2 0x00005560c955f4f5 llvm::sys::CleanupOnSignal(unsigned long)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2aaf4f5)
 #3 0x00005560c94d9200 CrashRecoverySignalHandler(int)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2a29200)
 #4 0x00007f6331726890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
 #5 0x00005560c8efaad0 llvm::Value::getContext() const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x244aad0)
 #6 0x00005560c8e82367 llvm::StoreInst::StoreInst(llvm::Value*, llvm::Value*,
bool, llvm::MaybeAlign, llvm::AtomicOrdering, unsigned char,
llvm::Instruction*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x23d2367)
 #7 0x00005560c8e82413 llvm::StoreInst::StoreInst(llvm::Value*, llvm::Value*,
bool, llvm::MaybeAlign, llvm::Instruction*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x23d2413)
 #8 0x00005560c9a6ab5a
clang::CodeGen::CodeGenFunction::EmitStoreOfScalar(llvm::Value*,
clang::CodeGen::Address, bool, clang::QualType, clang::CodeGen::LValueBaseInfo,
clang::CodeGen::TBAAAccessInfo, bool, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2fbab5a)
 #9 0x00005560c9a7b8ca
clang::CodeGen::CodeGenFunction::EmitStoreThroughLValue(clang::CodeGen::RValue,
clang::CodeGen::LValue, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2fcb8ca)
#10 0x00005560c9a483b2
clang::CodeGen::CodeGenFunction::EmitScalarInit(clang::Expr const*,
clang::ValueDecl const*, clang::CodeGen::LValue, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2f983b2)
#11 0x00005560c9a57491
clang::CodeGen::CodeGenFunction::EmitCXXGlobalVarDeclInit(clang::VarDecl
const&, llvm::Constant*, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2fa7491)
#12 0x00005560c9a57631
clang::CodeGen::CodeGenFunction::GenerateCXXGlobalVarDeclInitFunc(llvm::Function*,
clang::VarDecl const*, llvm::GlobalVariable*, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2fa7631)
#13 0x00005560c9a57b5b
clang::CodeGen::CodeGenModule::EmitCXXGlobalVarDeclInitFunc(clang::VarDecl
const*, llvm::GlobalVariable*, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2fa7b5b)
#14 0x00005560c98692a1
clang::CodeGen::CodeGenModule::EmitGlobalVarDefinition(clang::VarDecl const*,
bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x2db92a1)
#15 0x00005560c988314f
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x2dd314f)
#16 0x00005560c9883983
clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2dd3983)
#17 0x00005560c9888ee7
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.4849)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2dd8ee7)
#18 0x00005560ca2ec681 (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x383c681)
#19 0x00005560ca2df936
clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x382f936)
#20 0x00005560cafd4f84 clang::ParseAST(clang::Sema&, bool, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4524f84)
#21 0x00005560c9d27939 clang::FrontendAction::Execute()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3277939)
#22 0x00005560c9ce426a
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x323426a)
#23 0x00005560c9defcfb
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x333fcfb)
#24 0x00005560c7840aec cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xd90aec)
#25 0x00005560c783d91d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0xd8d91d)
#26 0x00005560c9bc4f25 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+++0x3114f25)
#27 0x00005560c94d92e3
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2a292e3)
#28 0x00005560c9bc5ba0
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.148)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3115ba0)
#29 0x00005560c9b9fd45
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x30efd45)
#30 0x00005560c9ba07a1
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+++0x30f07a1)
#31 0x00005560c9ba9395
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x30f9395)
#32 0x00005560c777a12e main
(/opt/compiler-explorer/clang-trunk/bin/clang+++0xcca12e)
#33 0x00007f63305e4b97 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21b97)
#34 0x00005560c783d49a _start
(/opt/compiler-explorer/clang-trunk/bin/clang+++0xd8d49a)
clang-11: error: clang frontend command failed due to signal (use -v to see
invocation)
Compiler returned: 254</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>