[llvm-bugs] [Bug 46419] New: Clang crash : Assertion `isExprRep((TST) TypeSpecType) && "DeclSpec does not store an expr"' failed.

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Jun 27 17:54:51 PDT 2020


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

            Bug ID: 46419
           Summary: Clang crash : Assertion `isExprRep((TST) TypeSpecType)
                    && "DeclSpec does not store an expr"' failed.
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Keywords: crash-on-invalid
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: haoxintu at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk
           Summary: Clang crash : Assertion `isExprRep((TST) TypeSpecType)
                    && "DeclSpec does not store an expr"' failed.

This code, bug.cc, it's an invalid code but crashes Clang.

$cat bug.cc
a = b.~decltype(auto)

$clang++ bug.cc
bug.cc:1:1: error: C++ requires a type specifier for all declarations
a = b.~decltype(auto)
^
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:
/home/haoxin/compilers/llvm-clang/llvm-project/build/bin/clang-11 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-disable-llvm-verifier -discard-value-names -main-file-name bug.cc
-mrelocation-model static -mthread-model posix -mframe-pointer=all -fmath-errno
-fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64
-dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir
/home/haoxin/compilers/llvm-clang/llvm-project/build/lib/clang/11.0.0
-internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/backward
-internal-isystem /usr/local/include -internal-isystem
/home/haoxin/compilers/llvm-clang/llvm-project/build/lib/clang/11.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/haoxin/test -ferror-limit 19
-fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -faddrsig -o
/tmp/bug-4b5eb6.o -x c++ bug.cc 
1.      <eof> parser at end of file
 #0 0x0000555d7095e7da llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/haoxin/compilers/llvm-clang/llvm-project/build/bin/clang-11+0x2b697da)
 #1 0x0000555d7095c5a4 llvm::sys::RunSignalHandlers()
(/home/haoxin/compilers/llvm-clang/llvm-project/build/bin/clang-11+0x2b675a4)
 #2 0x0000555d7095c6f3 SignalHandler(int)
(/home/haoxin/compilers/llvm-clang/llvm-project/build/bin/clang-11+0x2b676f3)
 #3 0x00007f3f60cf7890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
 #4 0x0000555d728f1504 clang::Sema::BuildDecltypeType(clang::Expr*,
clang::SourceLocation, bool)
(/home/haoxin/compilers/llvm-clang/llvm-project/build/bin/clang-11+0x4afc504)
 #5 0x0000555d7259d86f clang::Sema::ActOnPseudoDestructorExpr(clang::Scope*,
clang::Expr*, clang::SourceLocation, clang::tok::TokenKind,
clang::SourceLocation, clang::DeclSpec const&)
(/home/haoxin/compilers/llvm-clang/llvm-project/build/bin/clang-11+0x47a886f)
 #6 0x0000555d721f3593 clang::Parser::ParseCXXPseudoDestructor(clang::Expr*,
clang::SourceLocation, clang::tok::TokenKind, clang::CXXScopeSpec&,
clang::OpaquePtr<clang::QualType>)
(/home/haoxin/compilers/llvm-clang/llvm-project/build/bin/clang-11+0x43fe593)
 #7 0x0000555d721e78b0
clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*,
true>)
(/home/haoxin/compilers/llvm-clang/llvm-project/build/bin/clang-11+0x43f28b0)
 #8 0x0000555d721e21f5
clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&,
clang::Parser::TypeCastState, bool, bool*)
(/home/haoxin/compilers/llvm-clang/llvm-project/build/bin/clang-11+0x43ed1f5)
 #9 0x0000555d721e4936
clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool,
clang::Parser::TypeCastState, bool, bool*)
(/home/haoxin/compilers/llvm-clang/llvm-project/build/bin/clang-11+0x43ef936)
#10 0x0000555d721e5bd4
clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState)
(/home/haoxin/compilers/llvm-clang/llvm-project/build/bin/clang-11+0x43f0bd4)
#11 0x0000555d721b0c22
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*)
(/home/haoxin/compilers/llvm-clang/llvm-project/build/bin/clang-11+0x43bbc22)
#12 0x0000555d721c3895 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/home/haoxin/compilers/llvm-clang/llvm-project/build/bin/clang-11+0x43ce895)
#13 0x0000555d7219a809
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/home/haoxin/compilers/llvm-clang/llvm-project/build/bin/clang-11+0x43a5809)
#14 0x0000555d7219b501
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.227)
(/home/haoxin/compilers/llvm-clang/llvm-project/build/bin/clang-11+0x43a6501)
#15 0x0000555d721a13e9
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/home/haoxin/compilers/llvm-clang/llvm-project/build/bin/clang-11+0x43ac3e9)
#16 0x0000555d721a2af9
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/home/haoxin/compilers/llvm-clang/llvm-project/build/bin/clang-11+0x43adaf9)
#17 0x0000555d721a3155
clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/home/haoxin/compilers/llvm-clang/llvm-project/build/bin/clang-11+0x43ae155)
#18 0x0000555d72196733 clang::ParseAST(clang::Sema&, bool, bool)
(/home/haoxin/compilers/llvm-clang/llvm-project/build/bin/clang-11+0x43a1733)
#19 0x0000555d71140a79 clang::FrontendAction::Execute()
(/home/haoxin/compilers/llvm-clang/llvm-project/build/bin/clang-11+0x334ba79)
#20 0x0000555d710fbc43
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/haoxin/compilers/llvm-clang/llvm-project/build/bin/clang-11+0x3306c43)
#21 0x0000555d712055ab
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/haoxin/compilers/llvm-clang/llvm-project/build/bin/clang-11+0x34105ab)
#22 0x0000555d6eba74ec cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
(/home/haoxin/compilers/llvm-clang/llvm-project/build/bin/clang-11+0xdb24ec)
#23 0x0000555d6eba411d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/home/haoxin/compilers/llvm-clang/llvm-project/build/bin/clang-11+0xdaf11d)
#24 0x0000555d6eaf2911 main
(/home/haoxin/compilers/llvm-clang/llvm-project/build/bin/clang-11+0xcfd911)
#25 0x00007f3f5f940b97 __libc_start_main
/build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344:0
#26 0x0000555d6eba3c9a _start
(/home/haoxin/compilers/llvm-clang/llvm-project/build/bin/clang-11+0xdaec9a)
clang-11: error: unable to execute command: Segmentation fault (core dumped)
clang-11: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 11.0.0 (https://github.com/llvm/llvm-project
e6aba43cda848f4a8cfa5ce9f174b77def10e9df)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/haoxin/compilers/llvm-clang/llvm-project/build/bin
clang-11: note: diagnostic msg: 
********************

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

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


$clang++ --version
clang version 11.0.0 (https://github.com/llvm/llvm-project
e6aba43cda848f4a8cfa5ce9f174b77def10e9df)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/haoxin/compilers/llvm-clang/llvm-project/build/bin

Reproduced in newer trunk : https://godbolt.org/z/z6EzeH

--- Comment #1 from Haoxin Tu <haoxintu at gmail.com> ---
Noted that this case is reduced by C-Reduce.

And another case

a(){
= b.decltype(auto)

It also reproduced this issue. Although the StackTrace is different in some
way, I think it's the same issue.

--- Comment #2 from Haoxin Tu <haoxintu at gmail.com> ---
Add assertion information.

clang-11:
/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master-assert/clang/include/clang/Sema/DeclSpec.h:501:
clang::Expr *clang::DeclSpec::getRepAsExpr() const: Assertion `isExprRep((TST)
TypeSpecType) && "DeclSpec does not store an expr"' failed.

-- 
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/20200628/60b73b50/attachment-0001.html>


More information about the llvm-bugs mailing list