[llvm-bugs] [Bug 42049] New: Hitting clang assert with C++ template test

via llvm-bugs llvm-bugs at lists.llvm.org
Tue May 28 14:48:23 PDT 2019


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

            Bug ID: 42049
           Summary: Hitting clang assert with C++ template test
           Product: clang
           Version: trunk
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nicolean at ca.ibm.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

Created attachment 22034
  --> https://bugs.llvm.org/attachment.cgi?id=22034&action=edit
Output of clang command reproducing the assert documented in this issue.

The following test is failing with the below assert (clang++ -c t2.cpp):

$cat t2.cpp
template <typename T>
void f(T t) {
  g<decltype>(t);
}



Output:
t2.cpp:3:13: error: expected '(' after 'decltype'
  g<decltype>(t);
            ^
            (
clang-9: /home/nicolean/inv/clang/lib/Lex/PPCaching.cpp:120: void
clang::Preprocessor::AnnotatePreviousCachedTokens(const clang::Token &):
Assertion `CachedTokens[CachedLexPos-1].getLastLoc() ==
Tok.getAnnotationEndLoc() && "The annotation should be until the most recent
cached token"' failed.
Stack dump:
0.      Program arguments: /home/nicolean/install/bin/clang-9 -cc1 -triple
powerpc64le-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-main-file-name t2.cpp -mrelocation-model static -mthread-model posix
-mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases
-fuse-init-array -target-cpu ppc64le -mfloat-abi hard -target-abi elfv2
-dwarf-column-info -debugger-tuning=gdb -coverage-notes-file
/home/nicolean/inv/t2.gcno -resource-dir /home/nicolean/install/lib/clang/9.0.0
-internal-isystem
/usr/lib/gcc/powerpc64le-linux-gnu/7.3.0/../../../../include/c++/7.3.0
-internal-isystem
/usr/lib/gcc/powerpc64le-linux-gnu/7.3.0/../../../../include/powerpc64le-linux-gnu/c++/7.3.0
-internal-isystem
/usr/lib/gcc/powerpc64le-linux-gnu/7.3.0/../../../../include/powerpc64le-linux-gnu/c++/7.3.0
-internal-isystem
/usr/lib/gcc/powerpc64le-linux-gnu/7.3.0/../../../../include/c++/7.3.0/backward
-internal-isystem /home/nicolean/install/lib/clang/9.0.0/include/ppc_wrappers
-internal-isystem /usr/local/include -internal-isystem
/home/nicolean/install/lib/clang/9.0.0/include -internal-externc-isystem
/usr/include/powerpc64le-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -fdeprecated-macro
-fdebug-compilation-dir /home/nicolean/inv -ferror-limit 19 -fmessage-length 0
-fno-signed-char -fobjc-runtime=gcc -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -faddrsig -o t2.o -x c++ t2.cpp
1.      t2.cpp:3:6: at annotation token
2.      t2.cpp:2:13: parsing function body 'f'
3.      t2.cpp:2:13: in compound statement ('{}')
 #0 0x0000728fd2dca374 PrintStackTraceSignalHandler(void*)
(/home/nicolean/install/bin/../lib/libLLVMSupport.so.9svn+0x1ca374)
 #1 0x0000728fd2dc7598 llvm::sys::RunSignalHandlers()
(/home/nicolean/install/bin/../lib/libLLVMSupport.so.9svn+0x1c7598)
 #2 0x0000728fd2dca7c0 SignalHandler(int)
(/home/nicolean/install/bin/../lib/libLLVMSupport.so.9svn+0x1ca7c0)
 #3 0x0000728fd85d04d8 (linux-vdso64.so.1+0x4d8)
 #4 0x0000728fd103e98c __libc_signal_restore_set
/build/glibc-uvws04/glibc-2.27/signal/../sysdeps/unix/sysv/linux/nptl-signals.h:80:0
 #5 0x0000728fd103e98c raise
/build/glibc-uvws04/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:48:0
 #6 0x0000728fd1040be0 abort /build/glibc-uvws04/glibc-2.27/stdlib/abort.c:79:0
 #7 0x0000728fd102bb38 __assert_fail_base
/build/glibc-uvws04/glibc-2.27/assert/assert.c:92:0
 #8 0x0000728fd102bbe4 __assert_fail
/build/glibc-uvws04/glibc-2.27/assert/assert.c:101:0
 #9 0x0000728fcf9ec0d8
clang::Preprocessor::AnnotatePreviousCachedTokens(clang::Token const&)
(/home/nicolean/install/bin/../lib/../lib/libclangLex.so.9svn+0x6c0d8)
#10 0x0000728fcf5a7ef8
clang::Parser::AnnotateExistingDecltypeSpecifier(clang::DeclSpec const&,
clang::SourceLocation, clang::SourceLocation)
(/home/nicolean/install/bin/../lib/../lib/libclangParse.so.9svn+0x67ef8)
#11 0x0000728fcf5ca848
clang::Parser::ParseOptionalCXXScopeSpecifier(clang::CXXScopeSpec&,
clang::OpaquePtr<clang::QualType>, bool, bool*, bool, clang::IdentifierInfo**,
bool) (/home/nicolean/install/bin/../lib/../lib/libclangParse.so.9svn+0x8a848)
#12 0x0000728fcf634044 clang::Parser::TryAnnotateTypeOrScopeToken()
(/home/nicolean/install/bin/../lib/../lib/libclangParse.so.9svn+0xf4044)
#13 0x0000728fcf624734
clang::Parser::isCXXDeclarationSpecifier(clang::Parser::TPResult, bool*)
(/home/nicolean/install/bin/../lib/../lib/libclangParse.so.9svn+0xe4734)
#14 0x0000728fcf628338 clang::Parser::isTemplateArgumentList(unsigned int)
(/home/nicolean/install/bin/../lib/../lib/libclangParse.so.9svn+0xe8338)
#15 0x0000728fcf5cb230
clang::Parser::ParseOptionalCXXScopeSpecifier(clang::CXXScopeSpec&,
clang::OpaquePtr<clang::QualType>, bool, bool*, bool, clang::IdentifierInfo**,
bool) (/home/nicolean/install/bin/../lib/../lib/libclangParse.so.9svn+0x8b230)
#16 0x0000728fcf632e04 clang::Parser::TryAnnotateName(bool,
clang::CorrectionCandidateCallback*)
(/home/nicolean/install/bin/../lib/../lib/libclangParse.so.9svn+0xf2e04)
#17 0x0000728fcf60d740
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&)
(/home/nicolean/install/bin/../lib/../lib/libclangParse.so.9svn+0xcd740)
#18 0x0000728fcf60d334
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*)
(/home/nicolean/install/bin/../lib/../lib/libclangParse.so.9svn+0xcd334)
#19 0x0000728fcf615a24 clang::Parser::ParseCompoundStatementBody(bool)
(/home/nicolean/install/bin/../lib/../lib/libclangParse.so.9svn+0xd5a24)
#20 0x0000728fcf61682c clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&)
(/home/nicolean/install/bin/../lib/../lib/libclangParse.so.9svn+0xd682c)
#21 0x0000728fcf63186c
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*)
(/home/nicolean/install/bin/../lib/../lib/libclangParse.so.9svn+0xf186c)
#22 0x0000728fcf61f054
clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext,
clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
(/home/nicolean/install/bin/../lib/../lib/libclangParse.so.9svn+0xdf054)
#23 0x0000728fcf61db8c
clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
(/home/nicolean/install/bin/../lib/../lib/libclangParse.so.9svn+0xddb8c)
#24 0x0000728fcf61d478
clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
(/home/nicolean/install/bin/../lib/../lib/libclangParse.so.9svn+0xdd478)
#25 0x0000728fcf58841c
clang::Parser::ParseDeclaration(clang::DeclaratorContext,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&)
(/home/nicolean/install/bin/../lib/../lib/libclangParse.so.9svn+0x4841c)
#26 0x0000728fcf62e5f8
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/home/nicolean/install/bin/../lib/../lib/libclangParse.so.9svn+0xee5f8)
#27 0x0000728fcf62cf78
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/home/nicolean/install/bin/../lib/../lib/libclangParse.so.9svn+0xecf78)
#28 0x0000728fcf62c94c
clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/home/nicolean/install/bin/../lib/../lib/libclangParse.so.9svn+0xec94c)
#29 0x0000728fcf5735b4 clang::ParseAST(clang::Sema&, bool, bool)
(/home/nicolean/install/bin/../lib/../lib/libclangParse.so.9svn+0x335b4)
#30 0x0000728fd19cd0c8 clang::ASTFrontendAction::ExecuteAction()
(/home/nicolean/install/bin/../lib/libclangFrontend.so.9svn+0xed0c8)
#31 0x0000728fd20553c0 clang::CodeGenAction::ExecuteAction()
(/home/nicolean/install/bin/../lib/libclangCodeGen.so.9svn+0x3a53c0)
#32 0x0000728fd19cc790 clang::FrontendAction::Execute()
(/home/nicolean/install/bin/../lib/libclangFrontend.so.9svn+0xec790)
#33 0x0000728fd1974384
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/nicolean/install/bin/../lib/libclangFrontend.so.9svn+0x94384)
#34 0x0000728fd18b4668
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/nicolean/install/bin/../lib/libclangFrontendTool.so.9svn+0x4668)
#35 0x0000000010014f20 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/nicolean/install/bin/clang-9+0x10014f20)
#36 0x00000000100123a0 main (/home/nicolean/install/bin/clang-9+0x100123a0)
#37 0x0000728fd101441c generic_start_main
/build/glibc-uvws04/glibc-2.27/csu/../csu/libc-start.c:310:0
#38 0x0000728fd1014618 __libc_start_main
/build/glibc-uvws04/glibc-2.27/csu/../sysdeps/unix/sysv/linux/powerpc/libc-start.c:116:0
clang-9: error: unable to execute command: Aborted (core dumped)
clang-9: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 9.0.0 (https://github.com/llvm-mirror/clang.git
173708d165c6145075ef941e6953f2c1c1167544)
(https://github.com/llvm-mirror/llvm.git
e0b950eae9b2739c40e155339c7d0f9350399980)
Target: powerpc64le-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/nicolean/inv/../install/bin
clang-9: 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-9: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-9: note: diagnostic msg: /tmp/t2-8430b7.cpp
clang-9: note: diagnostic msg: /tmp/t2-8430b7.sh
clang-9: 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/20190528/9871f3ea/attachment.html>


More information about the llvm-bugs mailing list