[llvm-bugs] [Bug 43138] New: Declaration of reference variable causes clang to crash with segmentation fault

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 28 02:16:08 PDT 2019


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

            Bug ID: 43138
           Summary: Declaration of reference variable causes clang to
                    crash with segmentation fault
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: buchhold at kit.edu
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

The following line of code causes (at least) clang-7, clang-8 and clang-10 to
crash with segmentation fault.

int main() { static constexpr const int (&x)[] = {0}; }

Stack dump:
0.      Program arguments:
/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10 -cc1 -triple
x86_64-unknown-linux-gnu -S -disable-free -disable-llvm-verifier
-discard-value-names -main-file-name example.cpp -mrelocation-model static
-mthread-model posix -mframe-pointer=all -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64
-dwarf-column-info -debug-info-kind=limited -dwarf-version=4
-debugger-tuning=gdb -coverage-notes-file /home/ubuntu/./output.gcno
-resource-dir /opt/compiler-explorer/clang-trunk-20190826/lib/clang/10.0.0
-internal-isystem
/opt/compiler-explorer/gcc-8.3.0/lib/gcc/x86_64-linux-gnu/8.3.0/../../../../include/c++/8.3.0
-internal-isystem
/opt/compiler-explorer/gcc-8.3.0/lib/gcc/x86_64-linux-gnu/8.3.0/../../../../include/c++/8.3.0/x86_64-linux-gnu
-internal-isystem
/opt/compiler-explorer/gcc-8.3.0/lib/gcc/x86_64-linux-gnu/8.3.0/../../../../include/c++/8.3.0/backward
-internal-isystem /usr/local/include -internal-isystem
/opt/compiler-explorer/clang-trunk-20190826/lib/clang/10.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-fdeprecated-macro -fdebug-compilation-dir /home/ubuntu -ferror-limit 19
-fmessage-length 0 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -fcolor-diagnostics -mllvm --x86-asm-syntax=intel
-faddrsig -o ./output.s -x c++ <source> 
1.      <eof> parser at end of file
2.      <source>:1:5: LLVM IR generation of declaration 'main'
3.      <source>:1:5: Generating code for declaration 'main'
 #0 0x000055d149f5494a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x281794a)
 #1 0x000055d149f526e4 llvm::sys::RunSignalHandlers()
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x28156e4)
 #2 0x000055d149f52822 SignalHandler(int)
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x2815822)
 #3 0x00007fba17383890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
 #4 0x000055d14a1b2520
clang::CodeGen::ConstantEmitter::tryEmitPrivate(clang::APValue const&,
clang::QualType)
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x2a75520)
 #5 0x000055d14a1b335f
clang::CodeGen::ConstantEmitter::tryEmitPrivateForMemory(clang::APValue const&,
clang::QualType)
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x2a7635f)
 #6 0x000055d14a2231f0
clang::CodeGen::CodeGenModule::GetAddrOfGlobalTemporary(clang::MaterializeTemporaryExpr
const*, clang::Expr const*)
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x2ae61f0)
 #7 0x000055d14a1b30d0
clang::CodeGen::ConstantEmitter::tryEmitPrivate(clang::APValue const&,
clang::QualType)
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x2a760d0)
 #8 0x000055d14a1b335f
clang::CodeGen::ConstantEmitter::tryEmitPrivateForMemory(clang::APValue const&,
clang::QualType)
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x2a7635f)
 #9 0x000055d14a1b57ad
clang::CodeGen::ConstantEmitter::tryEmitPrivateForVarInit(clang::VarDecl
const&) (/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x2a787ad)
#10 0x000055d14a1b5a50
clang::CodeGen::ConstantEmitter::tryEmitForInitializer(clang::VarDecl const&)
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x2a78a50)
#11 0x000055d14a383f3a
clang::CodeGen::CodeGenFunction::AddInitializerToStaticVarDecl(clang::VarDecl
const&, llvm::GlobalVariable*)
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x2c46f3a)
#12 0x000055d14a388669
clang::CodeGen::CodeGenFunction::EmitStaticVarDecl(clang::VarDecl const&,
llvm::GlobalValue::LinkageTypes)
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x2c4b669)
#13 0x000055d14a38be85 clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl
const&) (/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x2c4ee85)
#14 0x000055d14a1c0bf7
clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&)
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x2a83bf7)
#15 0x000055d14a1cd8d5
clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*)
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x2a908d5)
#16 0x000055d14a1c9bcc clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt
const*, llvm::ArrayRef<clang::Attr const*>)
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x2a8cbcc)
#17 0x000055d14a1ca20c
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot)
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x2a8d20c)
#18 0x000055d14a205411
clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*)
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x2ac8411)
#19 0x000055d14a20d50e
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&)
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x2ad050e)
#20 0x000055d14a24bf89
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*)
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x2b0ef89)
#21 0x000055d14a249d75
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*)
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x2b0cd75)
#22 0x000055d14a24a493
clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl)
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x2b0d493)
#23 0x000055d14a24f4b7
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.4576)
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x2b124b7)
#24 0x000055d14acd2271 (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef)
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x3595271)
#25 0x000055d14acc6376
clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef)
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x3589376)
#26 0x000055d14b4e70c4 clang::ParseAST(clang::Sema&, bool, bool)
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x3daa0c4)
#27 0x000055d14acce8b2 clang::CodeGenAction::ExecuteAction()
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x35918b2)
#28 0x000055d14a6352f9 clang::FrontendAction::Execute()
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x2ef82f9)
#29 0x000055d14a5f6785
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x2eb9785)
#30 0x000055d14a6faac3
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0x2fbdac3)
#31 0x000055d14842b920 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0xcee920)
#32 0x000055d1483963da main
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0xc593da)
#33 0x00007fba16241b97 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21b97)
#34 0x000055d148428fba _start
(/opt/compiler-explorer/clang-trunk-20190826/bin/clang-10+0xcebfba)
clang-10: error: unable to execute command: Segmentation fault (core dumped)
clang-10: 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/20190828/dd2ecd47/attachment-0001.html>


More information about the llvm-bugs mailing list