[llvm-bugs] [Bug 52026] New: Clang crashes (Segmentation fault): template argument deduction + typo in template declaration

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 30 14:23:16 PDT 2021


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

            Bug ID: 52026
           Summary: Clang crashes (Segmentation fault): template argument
                    deduction + typo in template declaration
           Product: clang
           Version: 12.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: varqox at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Created attachment 25311
  --> https://bugs.llvm.org/attachment.cgi?id=25311&action=edit
Contains /tmp/abc-dbf30b.cpp and /tmp/abc-dbf30b.sh

Source (file abc.cc):
```cpp
template<class T>
struct Foo {
        template<class X...> // Notice the typo, should be template<class... X>
        Foo();
};

Foo x{};
```

Compilation command: clang++ abc.cc -std=c++17
System: Arch Linux

Compiler output:
abc.cc:3:21: error: non-type template parameter has incomplete type 'class X'
        template<class X...> // Notice the typo, should be template<class... X>
                           ^
abc.cc:3:17: note: forward declaration of 'X'
        template<class X...> // Notice the typo, should be template<class... X>
                       ^
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /usr/bin/clang-12 -cc1 -triple x86_64-pc-linux-gnu
-emit-obj -mrelax-all --mrelax-relocations -disable-free -disable-llvm-verifier
-discard-value-names -main-file-name abc.cc -mrelocation-model pic -pic-level 2
-pic-is-pie -mframe-pointer=all -fmath-errno -fno-rounding-math
-mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic
-fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir
/usr/lib/clang/12.0.1 -internal-isystem
/usr/sbin/../lib64/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../include/c++/11.1.0
-internal-isystem
/usr/sbin/../lib64/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../include/c++/11.1.0/x86_64-pc-linux-gnu
-internal-isystem
/usr/sbin/../lib64/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../include/c++/11.1.0/backward
-internal-isystem /usr/local/include -internal-isystem
/usr/lib/clang/12.0.1/include -internal-externc-isystem /include
-internal-externc-isystem /usr/include -std=c++17 -fdeprecated-macro
-fdebug-compilation-dir /tmp -ferror-limit 19 -stack-protector 2
-fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics
-faddrsig -o /tmp/abc-7a6160.o -x c++ abc.cc
1.      abc.cc:7:8: current parser token ';'
 #0 0x00007fb4832e8793 (/usr/bin/../lib/libLLVM-12.so+0xb49793)
 #1 0x00007fb4832e5e96 (/usr/bin/../lib/libLLVM-12.so+0xb46e96)
 #2 0x00007fb4823f9da0 __restore_rt (/usr/bin/../lib/libc.so.6+0x3cda0)
 #3 0x00007fb48a1b39e0
clang::Sema::DeclareImplicitDeductionGuides(clang::TemplateDecl*,
clang::SourceLocation) (/usr/bin/../lib/libclang-cpp.so.12+0x17699e0)
 #4 0x00007fb489f9408a (/usr/bin/../lib/libclang-cpp.so.12+0x154a08a)
 #5 0x00007fb489f94a85 clang::Sema::LookupQualifiedName(clang::LookupResult&,
clang::DeclContext*, bool) (/usr/bin/../lib/libclang-cpp.so.12+0x154aa85)
 #6 0x00007fb489f50846
clang::Sema::DeduceTemplateSpecializationFromInitializer(clang::TypeSourceInfo*,
clang::InitializedEntity const&, clang::InitializationKind const&,
llvm::MutableArrayRef<clang::Expr*>)
(/usr/bin/../lib/libclang-cpp.so.12+0x1506846)
 #7 0x00007fb489c339f4
clang::Sema::deduceVarTypeFromInitializer(clang::VarDecl*,
clang::DeclarationName, clang::QualType, clang::TypeSourceInfo*,
clang::SourceRange, bool, clang::Expr*)
(/usr/bin/../lib/libclang-cpp.so.12+0x11e99f4)
 #8 0x00007fb489c4ea9b
clang::Sema::DeduceVariableDeclarationType(clang::VarDecl*, bool, clang::Expr*)
(/usr/bin/../lib/libclang-cpp.so.12+0x1204a9b)
 #9 0x00007fb489c5208e clang::Sema::AddInitializerToDecl(clang::Decl*,
clang::Expr*, bool) (/usr/bin/../lib/libclang-cpp.so.12+0x120808e)
#10 0x00007fb4893999c6
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*)
(/usr/bin/../lib/libclang-cpp.so.12+0x94f9c6)
#11 0x00007fb4893aa0c4 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/usr/bin/../lib/libclang-cpp.so.12+0x9600c4)
#12 0x00007fb4894691e5 (/usr/bin/../lib/libclang-cpp.so.12+0xa1f1e5)
#13 0x00007fb48946f8ae
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/usr/bin/../lib/libclang-cpp.so.12+0xa258ae)
#14 0x00007fb48947092a
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/usr/bin/../lib/libclang-cpp.so.12+0xa2692a)
#15 0x00007fb489381432 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/bin/../lib/libclang-cpp.so.12+0x937432)
#16 0x00007fb48adcc2b9 clang::FrontendAction::Execute()
(/usr/bin/../lib/libclang-cpp.so.12+0x23822b9)
#17 0x00007fb48ad635be
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/bin/../lib/libclang-cpp.so.12+0x23195be)
#18 0x00007fb48ae4c999
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/bin/../lib/libclang-cpp.so.12+0x2402999)
#19 0x00005573b78c18de cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/bin/clang-12+0x128de)
#20 0x00005573b78beee8 (/usr/bin/clang-12+0xfee8)
#21 0x00005573b78bb505 main (/usr/bin/clang-12+0xc505)
#22 0x00007fb4823e4b25 __libc_start_main (/usr/bin/../lib/libc.so.6+0x27b25)
#23 0x00005573b78be86e _start (/usr/bin/clang-12+0xf86e)
clang-12: error: unable to execute command: Segmentation fault
clang-12: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 12.0.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/sbin
clang-12: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-12: note: diagnostic msg: /tmp/abc-dbf30b.cpp
clang-12: note: diagnostic msg: /tmp/abc-dbf30b.sh
clang-12: note: diagnostic msg: 

********************

-- 
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/20210930/05ba252c/attachment.html>


More information about the llvm-bugs mailing list