[llvm-bugs] [Bug 48495] New: template specialization with constraint in template class causes compiler to crash

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Dec 13 00:01:01 PST 2020


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

            Bug ID: 48495
           Summary: template specialization with constraint in template
                    class causes compiler to crash
           Product: clang
           Version: 10.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: dbronick at go.olemiss.edu
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

----------------------------System Info------------------------------

Linux Kernel 5.4.0-56-generic
Ubuntu 20.04.1 LTS
clang version 10.0.0-4ubuntu1

----------------------------Command Used-------------------------------

clang++ -std=c++20 test.cpp

---------------------------Code in Question------------------------------

template<int first, int second>
concept Equal = requires {first == second;};

template<int a>
struct Key_Info
{
        template<int pos>
                requires Equal<a, pos>
        struct Key_Inserted {};

        template<>
        struct Key_Inserted<0> {};
};

-----------------------------Additional Notes--------------------------

This is the smallest code snippet I could manage which still crashes the
compiler. The outer struct must be a template, the inner class must have a
specialization, and the inner class must have a constraint. (Using a concept
was the only way I could find to make this happen, though I'm not well versed
in constraints.)

-----------------------------Stack dump-----------------------------

Stack dump:
0.      Program arguments: /usr/lib/llvm-10/bin/clang -cc1 -triple
x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier
-discard-value-names -main-file-name test.cpp -mrelocation-model static
-mthread-model posix -mframe-pointer=all -fmath-errno -fno-rounding-math
-masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64
-dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir
/usr/lib/llvm-10/lib/clang/10.0.0 -internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/backward
-internal-isystem /usr/local/include -internal-isystem
/usr/lib/llvm-10/lib/clang/10.0.0/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -std=c++20 -fdeprecated-macro
-fdebug-compilation-dir /home/david/Documents/crash_report -ferror-limit 19
-fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fcxx-exceptions
-fexceptions -fdiagnostics-show-option -fcolor-diagnostics -faddrsig -o
/tmp/test-4fcc4f.o -x c++ test.cpp 
1.      test.cpp:12:25: current parser token '{'
2.      test.cpp:5:1: parsing struct/union/class body 'Key_Info'
 #0 0x00007faa1cc134ff llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/lib/x86_64-linux-gnu/libLLVM-10.so.1+0x9814ff)
 #1 0x00007faa1cc117b0 llvm::sys::RunSignalHandlers()
(/lib/x86_64-linux-gnu/libLLVM-10.so.1+0x97f7b0)
 #2 0x00007faa1cc13ac5 (/lib/x86_64-linux-gnu/libLLVM-10.so.1+0x981ac5)
 #3 0x00007faa233e33c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #4 0x00007faa213e4bd4 (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0xabebd4)
 #5 0x00007faa213bdbe3 (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0xa97be3)
 #6 0x00007faa213bfe6c (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0xa99e6c)
 #7 0x00007faa213bbfe8 clang::Expr::EvaluateAsRValue(clang::Expr::EvalResult&,
clang::ASTContext const&, bool) const
(/lib/x86_64-linux-gnu/libclang-cpp.so.10+0xa95fe8)
 #8 0x00007faa217b1115 (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0xe8b115)
 #9 0x00007faa217ac575
clang::Sema::CheckConstraintSatisfaction(clang::NamedDecl const*,
llvm::ArrayRef<clang::Expr const*>, llvm::ArrayRef<clang::TemplateArgument>,
clang::SourceRange, clang::ConstraintSatisfaction&)
(/lib/x86_64-linux-gnu/libclang-cpp.so.10+0xe86575)
#10 0x00007faa217ace67
clang::Sema::EnsureTemplateArgumentListConstraints(clang::TemplateDecl*,
llvm::ArrayRef<clang::TemplateArgument>, clang::SourceRange)
(/lib/x86_64-linux-gnu/libclang-cpp.so.10+0xe86e67)
#11 0x00007faa21bcdd46
clang::Sema::CheckTemplateArgumentList(clang::TemplateDecl*,
clang::SourceLocation, clang::TemplateArgumentListInfo&, bool,
llvm::SmallVectorImpl<clang::TemplateArgument>&, bool, bool*)
(/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x12a7d46)
#12 0x00007faa21be0056
clang::Sema::ActOnClassTemplateSpecialization(clang::Scope*, unsigned int,
clang::Sema::TagUseKind, clang::SourceLocation, clang::SourceLocation,
clang::CXXScopeSpec&, clang::TemplateIdAnnotation&, clang::ParsedAttributesView
const&, llvm::MutableArrayRef<clang::TemplateParameterList*>,
clang::Sema::SkipBodyInfo*)
(/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x12ba056)
#13 0x00007faa211aa125
clang::Parser::ParseClassSpecifier(clang::tok::TokenKind,
clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo
const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext,
clang::Parser::ParsedAttributesWithRange&)
(/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x884125)
#14 0x00007faa2118b664
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*)
(/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x865664)
#15 0x00007faa211ae46b
clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier,
clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo const&,
clang::ParsingDeclRAIIObject*)
(/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x88846b)
#16 0x00007faa21212f63
clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext,
clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
(/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x8ecf63)
#17 0x00007faa21212776
clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
(/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x8ec776)
#18 0x00007faa211addbe
clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier,
clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo const&,
clang::ParsingDeclRAIIObject*)
(/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x887dbe)
#19 0x00007faa211b0de6
clang::Parser::ParseCXXClassMemberDeclarationWithPragmas(clang::AccessSpecifier&,
clang::Parser::ParsedAttributesWithRange&, clang::TypeSpecifierType,
clang::Decl*) (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x88ade6)
#20 0x00007faa211ab4f5
clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation,
clang::SourceLocation, clang::Parser::ParsedAttributesWithRange&, unsigned int,
clang::Decl*) (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x8854f5)
#21 0x00007faa211a9152
clang::Parser::ParseClassSpecifier(clang::tok::TokenKind,
clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo
const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext,
clang::Parser::ParsedAttributesWithRange&)
(/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x883152)
#22 0x00007faa2118b664
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*)
(/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x865664)
#23 0x00007faa21213221
clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext,
clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
(/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x8ed221)
#24 0x00007faa21212776
clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
(/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x8ec776)
#25 0x00007faa21212174
clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
(/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x8ec174)
#26 0x00007faa2118ac70
clang::Parser::ParseDeclaration(clang::DeclaratorContext,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&,
clang::SourceLocation*) (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x864c70)
#27 0x00007faa2122286c
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x8fc86c)
#28 0x00007faa21221499
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x8fb499)
#29 0x00007faa2117bb8d clang::ParseAST(clang::Sema&, bool, bool)
(/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x855b8d)
#30 0x00007faa225f1e58 clang::FrontendAction::Execute()
(/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x1ccbe58)
#31 0x00007faa225aa8a1
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x1c848a1)
#32 0x00007faa22655daf
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x1d2fdaf)
#33 0x000000000041229d cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/lib/llvm-10/bin/clang+0x41229d)
#34 0x00000000004105b1 (/usr/lib/llvm-10/bin/clang+0x4105b1)
#35 0x000000000041036d main (/usr/lib/llvm-10/bin/clang+0x41036d)
#36 0x00007faa1bd7a0b3 __libc_start_main
/build/glibc-ZN95T4/glibc-2.31/csu/../csu/libc-start.c:342:3
#37 0x000000000040d7ce _start (/usr/lib/llvm-10/bin/clang+0x40d7ce)
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 10.0.0-4ubuntu1 
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg: PLEASE submit a bug report to
https://bugs.llvm.org/ and include the crash backtrace, preprocessed source,
and associated run script.
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/test-837341.cpp
clang: note: diagnostic msg: /tmp/test-837341.sh
clang: 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/20201213/8763d4d7/attachment-0001.html>


More information about the llvm-bugs mailing list