[llvm-bugs] [Bug 45294] New: Parser accepts undeclared identifier in pseudodestructor expression, then crashes

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Mar 24 08:07:01 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=45294

            Bug ID: 45294
           Summary: Parser accepts undeclared identifier in
                    pseudodestructor expression, then crashes
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: arthur.j.odwyer at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Inspired by https://bugs.llvm.org/show_bug.cgi?id=45142 -- thanks @rsmith for
fixing that one yesterday! Apparently the whole area of pseudodestructor
parsing is troublesome...

    // https://godbolt.org/z/yCP_nn
    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>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
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>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
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

-- 
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/20200324/d8a8325a/attachment-0001.html>


More information about the llvm-bugs mailing list