LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 49330 - bugprone-virtual-near-miss: Crash with template template parameter
Summary: bugprone-virtual-near-miss: Crash with template template parameter
Status: RESOLVED FIXED
Alias: None
Product: clang-tools-extra
Classification: Unclassified
Component: clang-tidy (show other bugs)
Version: unspecified
Hardware: PC Linux
: P enhancement
Assignee: Unassigned Clang Bugs
URL:
Keywords:
: 49370 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-02-23 04:28 PST by Volker Reichelt
Modified: 2021-02-27 11:39 PST (History)
6 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2021-02-23 04:28:30 PST
Running clang-tidy with -checks='-*,bugprone-virtual-near-miss' on the following valid source code triggers an assertion:

========================================================
template <template <int> class T> struct A : T<0>
{
  void foo();
};
========================================================

This is a recent regression between revision 9f581815ae4 and ba1d9546ee3.

clang-tidy: /llvm-project/llvm/include/llvm/Support/Casting.h:104: static bool llvm::isa_impl_cl<To, const From*>::doit(const From*) [with To = clang::CXXRecordDecl; From = clang::NamedDecl]: Assertion `Val && "isa<> used on a null pointer"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /LLVM-trunk/bin/clang-tidy -checks=-*,bugprone-virtual-near-miss CTbug.cc --
1.	<eof> parser at end of file
 #0 0x000000000273143c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/LLVM-trunk/bin/clang-tidy+0x273143c)
 #1 0x000000000272f294 llvm::sys::RunSignalHandlers() (/LLVM-trunk/bin/clang-tidy+0x272f294)
 #2 0x000000000272f3f3 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f990aa7c680 __restore_rt sigaction.c:0:0
 #4 0x00007f9909817207 raise (/lib64/libc.so.6+0x36207)
 #5 0x00007f99098188f8 abort (/lib64/libc.so.6+0x378f8)
 #6 0x00007f9909810026 __assert_fail_base (/lib64/libc.so.6+0x2f026)
 #7 0x00007f99098100d2 (/lib64/libc.so.6+0x2f0d2)
 #8 0x000000000059e5cd clang::tidy::bugprone::VirtualNearMissCheck::check(clang::ast_matchers::MatchFinder::MatchResult const&) (/LLVM-trunk/bin/clang-tidy+0x59e5cd)
 #9 0x0000000002040de1 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::MatchVisitor::visitMatch(clang::ast_matchers::BoundNodes const&) ASTMatchFinder.cpp:0:0
#10 0x00000000020804e7 clang::ast_matchers::internal::BoundNodesTreeBuilder::visitMatches(clang::ast_matchers::internal::BoundNodesTreeBuilder::Visitor*) (/LLVM-trunk/bin/clang-tidy+0x20804e7)
#11 0x0000000002042adb clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::matchWithFilter(clang::DynTypedNode const&) ASTMatchFinder.cpp:0:0
#12 0x0000000002063b7b clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#13 0x00000000020642aa clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDeclContextHelper(clang::DeclContext*) (.part.7214) ASTMatchFinder.cpp:0:0
#14 0x0000000002062b5c clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#15 0x0000000002063b86 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#16 0x0000000002079c3d clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseClassTemplateDecl(clang::ClassTemplateDecl*) ASTMatchFinder.cpp:0:0
#17 0x0000000002063b86 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#18 0x00000000020642aa clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDeclContextHelper(clang::DeclContext*) (.part.7214) ASTMatchFinder.cpp:0:0
#19 0x0000000002062ce4 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#20 0x0000000002063b86 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#21 0x0000000002063e45 clang::ast_matchers::MatchFinder::matchAST(clang::ASTContext&) (/LLVM-trunk/bin/clang-tidy+0x2063e45)
#22 0x00000000013f1428 clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) (/LLVM-trunk/bin/clang-tidy+0x13f1428)
#23 0x0000000001589849 clang::ParseAST(clang::Sema&, bool, bool) (/LLVM-trunk/bin/clang-tidy+0x1589849)
#24 0x00000000013d5c41 clang::FrontendAction::Execute() (/LLVM-trunk/bin/clang-tidy+0x13d5c41)
#25 0x0000000001367dd1 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/LLVM-trunk/bin/clang-tidy+0x1367dd1)
#26 0x0000000000d362be clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) (/LLVM-trunk/bin/clang-tidy+0xd362be)
#27 0x0000000000cea630 clang::tidy::runClangTidy(clang::tidy::ClangTidyContext&, clang::tooling::CompilationDatabase const&, llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>, bool, llvm::StringRef)::ActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) ClangTidy.cpp:0:0
#28 0x0000000000d2e444 clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContainerOperations>) (/LLVM-trunk/bin/clang-tidy+0xd2e444)
#29 0x0000000000d32d4d clang::tooling::ToolInvocation::run() (/LLVM-trunk/bin/clang-tidy+0xd32d4d)
#30 0x0000000000d35488 clang::tooling::ClangTool::run(clang::tooling::ToolAction*) (/LLVM-trunk/bin/clang-tidy+0xd35488)
#31 0x0000000000cf1a2e clang::tidy::runClangTidy(clang::tidy::ClangTidyContext&, clang::tooling::CompilationDatabase const&, llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>, bool, llvm::StringRef) (/LLVM-trunk/bin/clang-tidy+0xcf1a2e)
Comment 1 Nathan James 2021-02-23 06:58:03 PST
Likely introduced in https://github.com/llvm/llvm-project/commit/9a4b574dd6a07d6811356529ebb8a3f15d6e40a2, Author has been made aware
Comment 2 Nathan James 2021-02-27 10:37:10 PST
*** Bug 49370 has been marked as a duplicate of this bug. ***
Comment 3 Stephen Kelly 2021-02-27 11:39:37 PST
Thanks, reverted the offending commit.