Open Febbe opened 2 years ago
@llvm/issue-subscribers-bug
@llvm/issue-subscribers-clang-tidy
0. Program arguments: clang-tidy /data/llvm-project/.build/tools/clang/tools/extra/test/clang-tidy/checkers/modernize/Output/use-trailing-return-type-cxx20.cpp.tmp.cpp -fix --checks=-*,modernize-use-trailing-return-type --config={} -- -std=c++20 -nostdinc++
1. /data/llvm-project/.build/tools/clang/tools/extra/test/clang-tidy/checkers/modernize/Output/use-trailing-return-type-cxx20.cpp.tmp.cpp:91:2: current parser token ';'
2. /data/llvm-project/.build/tools/clang/tools/extra/test/clang-tidy/checkers/modernize/Output/use-trailing-return-type-cxx20.cpp.tmp.cpp:86:1: parsing struct/union/class body 'TestDefaultOperatorA'
#0 0x0000558820285e47 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /data/llvm-project/llvm/lib/Support/Unix/Signals.inc:567:13
#1 0x0000558820283c9e llvm::sys::RunSignalHandlers() /data/llvm-project/llvm/lib/Support/Signals.cpp:105:18
#2 0x00005588202867aa SignalHandler(int) /data/llvm-project/llvm/lib/Support/Unix/Signals.inc:412:1
#3 0x00007fe2782a4cf0 (/lib/x86_64-linux-gnu/libc.so.6+0x3bcf0)
#4 0x000055882044a5e3 hasExternalLexicalStorage /data/llvm-project/clang/include/clang/AST/DeclBase.h:2500:12
#5 0x000055882044a5e3 clang::RecordDecl::field_begin() const /data/llvm-project/clang/lib/AST/Decl.cpp:4767:7
#6 0x0000558820804128 operator!= /data/llvm-project/clang/include/clang/AST/DeclBase.h:2176:24
#7 0x0000558820804128 operator!= /data/llvm-project/clang/include/clang/AST/DeclBase.h:2266:24
#8 0x0000558820804128 __distance<clang::DeclContext::specific_decl_iterator<clang::FieldDecl> > /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_iterator_base_funcs.h:88:22
#9 0x0000558820804128 distance<clang::DeclContext::specific_decl_iterator<clang::FieldDecl> > /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_iterator_base_funcs.h:150:14
#10 0x0000558820804128 clang::ComparisonCategoryInfo::ValueInfo::hasValidIntValue() const /data/llvm-project/clang/lib/AST/ComparisonCategories.cpp:52:7
#11 0x00005588227a43bb clang::Sema::CheckComparisonCategoryType(clang::ComparisonCategoryType, clang::SourceLocation, clang::Sema::ComparisonCategoryUsage) /data/llvm-project/clang/lib/Sema/SemaDeclCXX.cpp:11514:9
#12 0x00005588227a1539 clang::Sema::CheckExplicitlyDefaultedComparison(clang::Scope*, clang::FunctionDecl*, clang::Sema::DefaultedComparisonKind) /data/llvm-project/clang/lib/Sema/SemaDeclCXX.cpp:8791:20
#13 0x000055882279ee33 clang::Sema::CheckExplicitlyDefaultedFunction(clang::Scope*, clang::FunctionDecl*) /data/llvm-project/clang/lib/Sema/SemaDeclCXX.cpp:7457:7
#14 0x000055882279c916 clang::Sema::CheckCompletedCXXClass(clang::Scope*, clang::CXXRecordDecl*) /data/llvm-project/clang/lib/Sema/SemaDeclCXX.cpp:0:5
#15 0x00005588227a7527 clang::Sema::ActOnFinishCXXMemberSpecification(clang::Scope*, clang::SourceLocation, clang::Decl*, clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributesView const&) /data/llvm-project/clang/lib/Sema/SemaDeclCXX.cpp:10227:1
#16 0x0000558822278de9 clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributes&, unsigned int, clang::Decl*) /data/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp:3611:7
#17 0x00005588222765bc clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::ParsedAttributes&) /data/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp:0:7
#18 0x000055882229977f empty /data/llvm-project/llvm/include/llvm/ADT/SmallVector.h:94:46
#19 0x000055882229977f empty /data/llvm-project/clang/include/clang/Sema/ParsedAttr.h:932:40
#20 0x000055882229977f clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) /data/llvm-project/clang/lib/Parse/ParseDecl.cpp:4237:23
#21 0x0000558822227b57 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /data/llvm-project/clang/lib/Parse/Parser.cpp:1125:10
#22 0x0000558822227809 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /data/llvm-project/clang/lib/Parse/Parser.cpp:1227:12
#23 0x00005588222267e5 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) /data/llvm-project/clang/lib/Parse/Parser.cpp:0:14
#24 0x000055882222463f clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) /data/llvm-project/clang/lib/Parse/Parser.cpp:744:10
#25 0x000055882221f1ce clang::ParseAST(clang::Sema&, bool, bool) /data/llvm-project/clang/lib/Parse/ParseAST.cpp:161:5
#26 0x0000558821f999b0 clang::FrontendAction::Execute() /data/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1062:10
#27 0x0000558821f066bf getPtr /data/llvm-project/llvm/include/llvm/Support/Error.h:272:42
#28 0x0000558821f066bf operator bool /data/llvm-project/llvm/include/llvm/Support/Error.h:235:16
#29 0x0000558821f066bf clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /data/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1049:23
#30 0x00005588203035ce clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) /data/llvm-project/clang/lib/Tooling/Tooling.cpp:434:33
#31 0x000055882034db88 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, bool, llvm::StringRef)::ActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) /data/llvm-project/clang-tools-extra/clang-tidy/ClangTidy.cpp:559:37
#32 0x0000558820303366 clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContainerOperations>) /data/llvm-project/clang/lib/Tooling/Tooling.cpp:409:18
#33 0x0000558820301d58 clang::tooling::ToolInvocation::run() /data/llvm-project/clang/lib/Tooling/Tooling.cpp:394:10
#34 0x000055882030503b clang::tooling::ClangTool::run(clang::tooling::ToolAction*) /data/llvm-project/clang/lib/Tooling/Tooling.cpp:588:11
#35 0x00005588203488a2 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, bool, llvm::StringRef) /data/llvm-project/clang-tools-extra/clang-tidy/ClangTidy.cpp:0:8
#36 0x0000558820251898 clang::tidy::clangTidyMain(int, char const**) /data/llvm-project/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp:659:7
#37 0x00007fe27828c510 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#38 0x00007fe27828c5c9 call_init ./csu/../csu/libc-start.c:128:20
#39 0x00007fe27828c5c9 __libc_start_main ./csu/../csu/libc-start.c:368:5
#40 0x000055882024cb65 _start (/data/llvm-project/.build/bin/clang-tidy+0x36a2b65)
Cause of crash is in clang/lib/AST/ComparisonCategories.cpp:51 ( auto *Record = VD->getType()->getAsCXXRecordDecl();)
We expecting record but we get:
QualType 0x5642fe4924c1 'const enum std::strong_ordering::Val' const
`-AutoType 0x5642fe4924c0 'enum std::strong_ordering::Val' sugar
`-EnumType 0x5642fe490c50 'enum std::strong_ordering::Val'
`-Enum 0x5642fe490b90 'Val'
and then there is nullptr dereference.
I dont know how this should be fixed, returning from this function with true/false causes: error: a type specifier is required for all declarations [clang-diagnostic-error]
so probably this should be fixed in other way.
@llvm/issue-subscribers-clang-frontend
Crashes also on Clang:
1.cpp:42:46: warning: volatile-qualified return type 'const floating_point auto *volatile' is deprecated [-Wdeprecated-volatile]
42 | const std::floating_point auto* volatile con4();
| ^
1.cpp:71:13: error: a type specifier is required for all declarations
71 | constexpr operator==(Val const &val) const { return this->val == val; }
| ~~~~~~~~~ ^
1.cpp:72:13: error: a type specifier is required for all declarations
72 | constexpr operator!=(Val const &val) const { return this->val != val; }
| ~~~~~~~~~ ^
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: clang++ -c 1.cpp -std=c++23
1. 1.cpp:91:2: current parser token ';'
2. 1.cpp:86:1: parsing struct/union/class body 'TestDefaultOperatorA'
#0 0x00007f721311c1ca llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-19/bin/../lib/libLLVM-19.so.1+0xd951ca)
#1 0x00007f7213119f64 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-19/bin/../lib/libLLVM-19.so.1+0xd92f64)
#2 0x00007f7213067c14 (/usr/lib/llvm-19/bin/../lib/libLLVM-19.so.1+0xce0c14)
#3 0x00007f7211e2c910 (/lib/x86_64-linux-gnu/libc.so.6+0x42910)
#4 0x00007f721a87a7d3 clang::RecordDecl::field_begin() const (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19+0xe227d3)
#5 0x00007f721a862fd5 clang::ComparisonCategoryInfo::ValueInfo::hasValidIntValue() const (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19+0xe0afd5)
#6 0x00007f721b07e467 clang::Sema::CheckComparisonCategoryType(clang::ComparisonCategoryType, clang::SourceLocation, clang::Sema::ComparisonCategoryUsage) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19+0x1626467)
#7 0x00007f721b07b8a4 clang::Sema::CheckExplicitlyDefaultedComparison(clang::Scope*, clang::FunctionDecl*, clang::Sema::DefaultedComparisonKind) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19+0x16238a4)
#8 0x00007f721b0791ec clang::Sema::CheckExplicitlyDefaultedFunction(clang::Scope*, clang::FunctionDecl*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19+0x16211ec)
#9 0x00007f721b07693d clang::Sema::CheckCompletedCXXClass(clang::Scope*, clang::CXXRecordDecl*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19+0x161e93d)
#10 0x00007f721b08108d clang::Sema::ActOnFinishCXXMemberSpecification(clang::Scope*, clang::SourceLocation, clang::Decl*, clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributesView const&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19+0x162908d)
#11 0x00007f721a62b5a7 clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributes&, unsigned int, clang::Decl*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19+0xbd35a7)
#12 0x00007f721a628d0d clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::ParsedAttributes&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19+0xbd0d0d)
#13 0x00007f721a609af8 clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19+0xbb1af8)
#14 0x00007f721a6bcb5f clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19+0xc64b5f)
#15 0x00007f721a6bc8af clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19+0xc648af)
#16 0x00007f721a6bbaeb clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19+0xc63aeb)
#17 0x00007f721a6b9f5a clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19+0xc61f5a)
#18 0x00007f721a5efdae clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19+0xb97dae)
#19 0x00007f721c463869 clang::FrontendAction::Execute() (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19+0x2a0b869)
#20 0x00007f721c3d9864 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19+0x2981864)
#21 0x00007f721c4dc17e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19+0x2a8417e)
#22 0x000056115685d676 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-19/bin/clang+0x14676)
#23 0x000056115685a945 (/usr/lib/llvm-19/bin/clang+0x11945)
#24 0x00007f721c08838d (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19+0x263038d)
#25 0x00007f72130679a4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/usr/lib/llvm-19/bin/../lib/libLLVM-19.so.1+0xce09a4)
#26 0x00007f721c087ca2 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19+0x262fca2)
#27 0x00007f721c04fd17 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19+0x25f7d17)
#28 0x00007f721c04ff6e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19+0x25f7f6e)
#29 0x00007f721c06c81d clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19+0x261481d)
#30 0x000056115685a29d clang_main(int, char**, llvm::ToolContext const&) (/usr/lib/llvm-19/bin/clang+0x1129d)
#31 0x000056115686787a main (/usr/lib/llvm-19/bin/clang+0x1e87a)
#32 0x00007f7211e120d0 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#33 0x00007f7211e12189 call_init ./csu/../csu/libc-start.c:128:20
#34 0x00007f7211e12189 __libc_start_main ./csu/../csu/libc-start.c:347:5
#35 0x00005611568572a5 _start (/usr/lib/llvm-19/bin/clang+0xe2a5)
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Ubuntu clang version 19.0.0 (++20240131083553+96c907dbcebd-1~exp1~20240131083715.288)
Calling
with `modernize-use-trailing-return-type-cxx20.cpp`
``` // RUN: %check_clang_tidy -std=c++20 %s modernize-use-trailing-return-type %t namespace std { templateCrashes with