[llvm-bugs] [Bug 46668] New: Clang crashed when parsing destructor with parameter. Assertion `(data().DefaultedDestructorIsDeleted || needsOverloadResolutionForDestructor()) && "destructor should not be deleted"' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jul 9 21:26:58 PDT 2020


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

            Bug ID: 46668
           Summary: Clang crashed when parsing destructor with parameter.
                    Assertion `(data().DefaultedDestructorIsDeleted ||
                    needsOverloadResolutionForDestructor()) && "destructor
                    should not be deleted"' failed
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          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

Hi,all.

This code, bug.cc, with a small mistake, makes Clang-trunk crashed.
Interestingly, Clang-10 or Clang-9 handles this well with no crash. This is a
regression problem I guess.

$cat bug.cc
class a { ~a(int); };
class b: virtual a {};

$clang++ bug.cc
bug.cc:1:11: error: destructor cannot have any parameters
class a { ~a(int); };
          ^
clang-11:
/home/tuhaoxin/compilers/llvm-project/clang/include/clang/AST/DeclCXX.h:854:
void clang::CXXRecordDecl::setImplicitDestructorIsDeleted(): Assertion
`(data().DefaultedDestructorIsDeleted ||
needsOverloadResolutionForDestructor()) && "destructor should not be deleted"'
failed.
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/tuhaoxin/compilers/llvm-project/build/bin/clang-11 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
bug.cc -mrelocation-model static -mframe-pointer=all -fmath-errno
-fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64
-fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir
/home/tuhaoxin/compilers/llvm-project/build/lib/clang/11.0.0 -c-isystem
/usr/local/include/csmith-2.3.0 -cxx-isystem /usr/local/include/csmith-2.3.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/tuhaoxin/compilers/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/tuhaoxin/gitee/run-new-scg/test-100000/creduce -ferror-limit 19
-fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics
-faddrsig -o /tmp/bug-d9245c.o -x c++ bug.cc 
1.      bug.cc:2:22: current parser token ';'
2.      bug.cc:2:1: parsing struct/union/class body 'b'
 #0 0x000000000272dac4 PrintStackTraceSignalHandler(void*)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-11+0x272dac4)
 #1 0x000000000272b6ce llvm::sys::RunSignalHandlers()
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-11+0x272b6ce)
 #2 0x000000000272dde5 SignalHandler(int)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-11+0x272dde5)
 #3 0x00007ff5a76638a0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x128a0)
 #4 0x00007ff5a60c1f47 raise
/build/glibc-2ORdQG/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #5 0x00007ff5a60c38b1 abort /build/glibc-2ORdQG/glibc-2.27/stdlib/abort.c:81:0
 #6 0x00007ff5a60b342a __assert_fail_base
/build/glibc-2ORdQG/glibc-2.27/assert/assert.c:89:0
 #7 0x00007ff5a60b34a2 (/lib/x86_64-linux-gnu/libc.so.6+0x304a2)
 #8 0x0000000004112c63
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-11+0x4112c63)
 #9 0x00000000041a1d8f
clang::Sema::ActOnFinishCXXMemberSpecification(clang::Scope*,
clang::SourceLocation, clang::Decl*, clang::SourceLocation,
clang::SourceLocation, clang::ParsedAttributesView const&)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-11+0x41a1d8f)
#10 0x0000000003ee0ec4
clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation,
clang::SourceLocation, clang::Parser::ParsedAttributesWithRange&, unsigned int,
clang::Decl*)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-11+0x3ee0ec4)
#11 0x0000000003edea81
clang::Parser::ParseClassSpecifier(clang::tok::TokenKind,
clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo
const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext,
clang::Parser::ParsedAttributesWithRange&)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-11+0x3edea81)
#12 0x0000000003ebf3b7
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-11+0x3ebf3b7)
#13 0x0000000003ea828a
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-11+0x3ea828a)
#14 0x0000000003ea7fb5
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-11+0x3ea7fb5)
#15 0x0000000003ea6d9f
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-11+0x3ea6d9f)
#16 0x0000000003ea4e0d
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-11+0x3ea4e0d)
#17 0x0000000003ea023d clang::ParseAST(clang::Sema&, bool, bool)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-11+0x3ea023d)
#18 0x0000000002f0e293 clang::FrontendAction::Execute()
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-11+0x2f0e293)
#19 0x0000000002ea4ce3
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-11+0x2ea4ce3)
#20 0x0000000002fbacb2
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-11+0x2fbacb2)
#21 0x000000000095e547 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/tuhaoxin/compilers/llvm-project/build/bin/clang-11+0x95e547)
#22 0x000000000095c5ac ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-11+0x95c5ac)
#23 0x000000000095c261 main
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-11+0x95c261)
#24 0x00007ff5a60a4b97 __libc_start_main
/build/glibc-2ORdQG/glibc-2.27/csu/../csu/libc-start.c:344:0
#25 0x000000000095927a _start
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-11+0x95927a)
clang-11: error: unable to execute command: Aborted (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.git
305b500eaf8c3b6a319e4571b4279a4694645d0d)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/tuhaoxin/compilers/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-9523e5.cpp
clang-11: note: diagnostic msg: /tmp/bug-9523e5.sh
clang-11: note: diagnostic msg: 

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

$clang++ -v
clang version 11.0.0 (https://github.com/llvm/llvm-project.git
305b500eaf8c3b6a319e4571b4279a4694645d0d)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/tuhaoxin/compilers/llvm-project/build/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Selected multilib: .;@m64


Thanks
Haoxin

-- 
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/20200710/ddc8d593/attachment-0001.html>


More information about the llvm-bugs mailing list