[llvm-bugs] [Bug 51527] New: clang++-12 crashes when parsing this C++17 program with inline variable templates

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 18 11:07:32 PDT 2021


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

            Bug ID: 51527
           Summary: clang++-12 crashes when parsing this C++17 program
                    with inline variable templates
           Product: new-bugs
           Version: 12.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: bspencer at blackberry.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

clang seems to crash when parsing this C++17 code.  I've minimized the code to
a point where it shouldn't successfully compile, but still crashes.

See the attachments for the source.  This is using the Debian 10 packages from
apt.llvm.org.  Version details below.  Source attached.

$ clang++-12 -std=c++17 -Wall -c -o foo.o foo.cc
foo.cc:10:22: error: no template named 'Bar'
constexpr auto bar = Bar<args...>::value;
                     ^
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: clang++-12 -std=c++17 -Wall -c -o foo.o foo.cc
1.      foo.cc:16:35: current parser token ';'
2.      foo.cc:13:1: parsing struct/union/class body 'Baz'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH
or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
/usr/lib/x86_64-linux-gnu/libLLVM-12.so.1(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamEi+0x23)[0x7f948bbf7b23]
/usr/lib/x86_64-linux-gnu/libLLVM-12.so.1(_ZN4llvm3sys17RunSignalHandlersEv+0x50)[0x7f948bbf5e50]
/usr/lib/x86_64-linux-gnu/libLLVM-12.so.1(_ZN4llvm3sys15CleanupOnSignalEm+0xdd)[0x7f948bbf727d]
/usr/lib/x86_64-linux-gnu/libLLVM-12.so.1(+0xc4bfd6)[0x7f948bb46fd6]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x12730)[0x7f948aeec730]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(_ZN5clang4Sema35SubstituteExplicitTemplateArgumentsEPNS_20FunctionTemplateDeclERNS_24TemplateArgumentListInfoERN4llvm15SmallVectorImplINS_23DeducedTemplateArgumentEEERNS6_INS_8QualTypeEEEPSA_RNS_4sema21TemplateDeductionInfoE+0x579)[0x7f94896d28f9]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(+0x158b363)[0x7f9489718363]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(_ZN5clang4Sema27runWithSufficientStackSpaceENS_14SourceLocationEN4llvm12function_refIFvvEEE+0x2b)[0x7f94891b63cb]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(_ZN5clang4Sema23DeduceTemplateArgumentsEPNS_20FunctionTemplateDeclEPNS_24TemplateArgumentListInfoENS_8QualTypeERPNS_12FunctionDeclERNS_4sema21TemplateDeductionInfoEb+0x198)[0x7f94896d6518]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(_ZN5clang4Sema23DeduceTemplateArgumentsEPNS_20FunctionTemplateDeclEPNS_24TemplateArgumentListInfoERPNS_12FunctionDeclERNS_4sema21TemplateDeductionInfoEb+0x15)[0x7f94896da405]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(_ZN5clang4Sema43ResolveSingleFunctionTemplateSpecializationEPNS_12OverloadExprEbPNS_14DeclAccessPairE+0x2ac)[0x7f948961139c]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(+0x154fb9e)[0x7f94896dcb9e]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(_ZN5clang4Sema14DeduceAutoTypeENS_7TypeLocERPNS_4ExprERNS_8QualTypeEN4llvm8OptionalIjEEb+0x712)[0x7f94896dab52]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(_ZN5clang4Sema14DeduceAutoTypeEPNS_14TypeSourceInfoERPNS_4ExprERNS_8QualTypeEN4llvm8OptionalIjEEb+0x20)[0x7f94896da430]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(_ZN5clang4Sema28deduceVarTypeFromInitializerEPNS_7VarDeclENS_15DeclarationNameENS_8QualTypeEPNS_14TypeSourceInfoENS_11SourceRangeEbPNS_4ExprE+0x53d)[0x7f94892f931d]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(_ZN5clang4Sema29DeduceVariableDeclarationTypeEPNS_7VarDeclEbPNS_4ExprE+0x65)[0x7f94892f9725]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(_ZN5clang4Sema20AddInitializerToDeclEPNS_4DeclEPNS_4ExprEb+0x19a)[0x7f94892f9c9a]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(_ZN5clang6Parser30ParseCXXClassMemberDeclarationENS_15AccessSpecifierERNS_16ParsedAttributesERKNS0_18ParsedTemplateInfoEPNS_21ParsingDeclRAIIObjectE+0x13fe)[0x7f9488bc323e]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(_ZN5clang6Parser41ParseCXXClassMemberDeclarationWithPragmasERNS_15AccessSpecifierERNS0_25ParsedAttributesWithRangeENS_17TypeSpecifierTypeEPNS_4DeclE+0x735)[0x7f9488bc53c5]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(_ZN5clang6Parser27ParseCXXMemberSpecificationENS_14SourceLocationES1_RNS0_25ParsedAttributesWithRangeEjPNS_4DeclE+0x97d)[0x7f9488bbf92d]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(_ZN5clang6Parser19ParseClassSpecifierENS_3tok9TokenKindENS_14SourceLocationERNS_8DeclSpecERKNS0_18ParsedTemplateInfoENS_15AccessSpecifierEbNS0_15DeclSpecContextERNS0_25ParsedAttributesWithRangeE+0x1534)[0x7f9488bbd324]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(_ZN5clang6Parser26ParseDeclarationSpecifiersERNS_8DeclSpecERKNS0_18ParsedTemplateInfoENS_15AccessSpecifierENS0_15DeclSpecContextEPNS0_18LateParsedAttrListE+0x33f)[0x7f9488b9e43f]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(_ZN5clang6Parser35ParseSingleDeclarationAfterTemplateENS_17DeclaratorContextERKNS0_18ParsedTemplateInfoERNS_21ParsingDeclRAIIObjectERNS_14SourceLocationERNS_16ParsedAttributesENS_15AccessSpecifierE+0x385)[0x7f9488c30d35]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(_ZN5clang6Parser40ParseTemplateDeclarationOrSpecializationENS_17DeclaratorContextERNS_14SourceLocationERNS_16ParsedAttributesENS_15AccessSpecifierE+0x4ce)[0x7f9488c3011e]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(_ZN5clang6Parser36ParseDeclarationStartingWithTemplateENS_17DeclaratorContextERNS_14SourceLocationERNS_16ParsedAttributesENS_15AccessSpecifierE+0xe4)[0x7f9488c2faf4]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(_ZN5clang6Parser16ParseDeclarationENS_17DeclaratorContextERNS_14SourceLocationERNS0_25ParsedAttributesWithRangeEPS2_+0x293)[0x7f9488b9dae3]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(_ZN5clang6Parser24ParseExternalDeclarationERNS0_25ParsedAttributesWithRangeEPNS_15ParsingDeclSpecE+0xac)[0x7f9488c3e7dc]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(_ZN5clang6Parser17ParseTopLevelDeclERNS_9OpaquePtrINS_12DeclGroupRefEEEb+0x4ff)[0x7f9488c3d7ff]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(_ZN5clang8ParseASTERNS_4SemaEbb+0x2ed)[0x7f9488b8e2ad]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(_ZN5clang14FrontendAction7ExecuteEv+0x48)[0x7f948a13c738]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(_ZN5clang16CompilerInstance13ExecuteActionERNS_14FrontendActionE+0x8a1)[0x7f948a0ca421]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(_ZN5clang25ExecuteCompilerInvocationEPNS_16CompilerInstanceE+0x632)[0x7f948a19f1a2]
clang++-12(_Z8cc1_mainN4llvm8ArrayRefIPKcEES2_Pv+0x9a2)[0x413352]
clang++-12[0x4116ce]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(+0x1c4f712)[0x7f9489ddc712]
/usr/lib/x86_64-linux-gnu/libLLVM-12.so.1(_ZN4llvm20CrashRecoveryContext9RunSafelyENS_12function_refIFvvEEE+0xdd)[0x7f948bb46dad]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(_ZNK5clang6driver10CC1Command7ExecuteEN4llvm8ArrayRefINS2_8OptionalINS2_9StringRefEEEEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPb+0x139)[0x7f9489ddbf19]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(_ZNK5clang6driver11Compilation14ExecuteCommandERKNS0_7CommandERPS3_+0x17f)[0x7f9489db134f]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(_ZNK5clang6driver11Compilation11ExecuteJobsERKNS0_7JobListERN4llvm15SmallVectorImplISt4pairIiPKNS0_7CommandEEEE+0x77)[0x7f9489db1707]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.12(_ZN5clang6driver6Driver18ExecuteCompilationERNS0_11CompilationERN4llvm15SmallVectorImplISt4pairIiPKNS0_7CommandEEEE+0xdc)[0x7f9489dc61bc]
clang++-12(main+0x2444)[0x410fa4]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xeb)[0x7f9487ccd09b]
clang++-12(_start+0x2a)[0x40e88a]
clang: error: clang frontend command failed with exit code 139 (use -v to see
invocation)
Debian clang version
12.0.1-++20210804103842+fed41342a82f-1~exp1~20210804084624.136
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
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/foo-f55deb.cpp
clang: note: diagnostic msg: /tmp/foo-f55deb.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/20210818/9cfabdd8/attachment-0001.html>


More information about the llvm-bugs mailing list