<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/93058>93058</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[AArch64] `target_version` multiversioned function crashes when defined as friend function
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
MitalAshok
</td>
</tr>
</table>
<pre>
https://godbolt.org/z/h1oE1sMb6
```c++
struct X {
friend void foo[[gnu::target_version("sve")]]() {}
};
```
```
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: /cmake-build-debug/clang++ -target aarch64-linux-gnu -fsyntax-only test.cpp
1. test.cpp:2:54: current parser token '}'
2. test.cpp:1:1: parsing struct/union/class body 'X'
3. test.cpp:2:53: parsing function body 'foo'
4. test.cpp:2:53: in compound statement ('{}')
#0 0x000055f307f0ac2d llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:11
#1 0x000055f307f0b11b PrintStackTraceSignalHandler(void*) /llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:798:1
#2 0x000055f307f09186 llvm::sys::RunSignalHandlers() /llvm/llvm-project/llvm/lib/Support/Signals.cpp:105:5
#3 0x000055f307f0a4ae llvm::sys::CleanupOnSignal(unsigned long) /llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:368:1
#4 0x000055f307e36d74 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) /llvm/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:0:7
#5 0x000055f307e37112 CrashRecoverySignalHandler(int) /llvm/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:391:1
#6 0x00007fdc916ac520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#7 0x000055f307e6ca3c llvm::SmallVectorBase<unsigned int>::size() const /llvm/llvm-project/llvm/include/llvm/ADT/SmallVector.h:91:32
#8 0x000055f30cae31dd clang::sema::CompoundScopeInfo const* llvm::SmallVectorTemplateCommon<clang::sema::CompoundScopeInfo, void>::reserveForParamAndGetAddressImpl<llvm::SmallVectorTemplateBase<clang::sema::CompoundScopeInfo, true> >(llvm::SmallVectorTemplateBase<clang::sema::CompoundScopeInfo, true>*, clang::sema::CompoundScopeInfo const&, unsigned long) /llvm/llvm-project/llvm/include/llvm/ADT/SmallVector.h:244:35
#9 0x000055f30cae3175 llvm::SmallVectorTemplateBase<clang::sema::CompoundScopeInfo, true>::reserveForParamAndGetAddress(clang::sema::CompoundScopeInfo&, unsigned long) /llvm/llvm-project/llvm/include/llvm/ADT/SmallVector.h:549:5#10 0x000055f30caba6a6 llvm::SmallVectorTemplateBase<clang::sema::CompoundScopeInfo, true>::push_back(clang::sema::CompoundScopeInfo) /llvm/llvm-project/llvm/include/llvm/ADT/SmallVector.h:575:23
#11 0x000055f30caab2f3 clang::Sema::PushCompoundScope(bool) /llvm/llvm-project/clang/lib/Sema/Sema.cpp:2291:1#12 0x000055f30dc0aee5 clang::Sema::ActOnStartOfCompoundStmt(bool) /llvm/llvm-project/clang/lib/Sema/SemaStmt.cpp:397:1
#13 0x000055f30c9cda63 clang::Sema::CompoundScopeRAII::CompoundScopeRAII(clang::Sema&, bool) /llvm/llvm-project/clang/include/clang/Sema/Sema.h:866:5
#14 0x000055f30c9c9d22 clang::Parser::ParseCompoundStatementBody(bool) /llvm/llvm-project/clang/lib/Parse/ParseStmt.cpp:1186:27
#15 0x000055f30c9cb847 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) /llvm/llvm-project/clang/lib/Parse/ParseStmt.cpp:2518:21
#16 0x000055f30c9be9c0 clang::Parser::ParseLexedMethodDef(clang::Parser::LexedMethod&) /llvm/llvm-project/clang/lib/Parse/ParseCXXInlineMethods.cpp:0:3
#17 0x000055f30c9be459 clang::Parser::LexedMethod::ParseLexedMethodDefs() /llvm/llvm-project/clang/lib/Parse/ParseCXXInlineMethods.cpp:321:1
#18 0x000055f30c9bd43a clang::Parser::ParseLexedMethodDefs(clang::Parser::ParsingClass&) /llvm/llvm-project/clang/lib/Parse/ParseCXXInlineMethods.cpp:574:33
#19 0x000055f30c9658da clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributes&, unsigned int, clang::Decl*) /llvm/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp:3826:5
#20 0x000055f30c963ac1 clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::ParsedAttributes&) /llvm/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp:2269:7
#21 0x000055f30c9a0430 clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) /llvm/llvm-project/clang/lib/Parse/ParseDecl.cpp:4607:23
#22 0x000055f30c8f6aa2 clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*) /llvm/llvm-project/clang/include/clang/Parse/Parser.h:2496:5
#23 0x000055f30c8ef428 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /llvm/llvm-project/clang/lib/Parse/Parser.cpp:1158:7
#24 0x000055f30c8eef4e clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /llvm/llvm-project/clang/lib/Parse/Parser.cpp:1271:12#25 0x000055f30c8ee7ca clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) /llvm/llvm-project/clang/lib/Parse/Parser.cpp:1074:14
#26 0x000055f30c8ec60c clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) /llvm/llvm-project/clang/lib/Parse/Parser.cpp:763:12
#27 0x000055f30c8ebcb0 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) /llvm/llvm-project/clang/lib/Parse/Parser.cpp:608:8
#28 0x000055f30c8e729b clang::ParseAST(clang::Sema&, bool, bool) /llvm/llvm-project/clang/lib/Parse/ParseAST.cpp:162:15
#29 0x000055f30941a871 clang::ASTFrontendAction::ExecuteAction() /llvm/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1194:1
#30 0x000055f30941a28c clang::FrontendAction::Execute() /llvm/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1082:7
#31 0x000055f30933830a clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /llvm/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1061:23
#32 0x000055f3095f360e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /llvm/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:280:8
#33 0x000055f306062ce1 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /llvm/llvm-project/clang/tools/driver/cc1_main.cpp:232:13
#34 0x000055f3060556b2 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /llvm/llvm-project/clang/tools/driver/driver.cpp:215:5
#35 0x000055f30605615d clang_main(int, char**, llvm::ToolContext const&)::$_0::operator()(llvm::SmallVectorImpl<char const*>&) const /llvm/llvm-project/clang/tools/driver/driver.cpp:355:7
#36 0x000055f30605612d int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::$_0>(long, llvm::SmallVectorImpl<char const*>&) /llvm/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:5
#37 0x000055f3091b88b1 llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::operator()(llvm::SmallVectorImpl<char const*>&) const /llvm/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:5
#38 0x000055f3091b5588 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const::$_1::operator()() const /llvm/llvm-project/clang/lib/Driver/Job.cpp:440:34
#39 0x000055f3091b5555 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const::$_1>(long) /llvm/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:5
#40 0x000055f306b16459 llvm::function_ref<void ()>::operator()() const /llvm/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:5
#41 0x000055f307e36b8a llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) /llvm/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:427:3
#42 0x000055f3091b4eeb clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const /llvm/llvm-project/clang/lib/Driver/Job.cpp:440:7
#43 0x000055f3091502ef clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const /llvm/llvm-project/clang/lib/Driver/Compilation.cpp:199:15
#44 0x000055f3091504f7 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&, bool) const /llvm/llvm-project/clang/lib/Driver/Compilation.cpp:253:13
#45 0x000055f30916b0b2 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) /llvm/llvm-project/clang/lib/Driver/Driver.cpp:1942:7
#46 0x000055f30605518b clang_main(int, char**, llvm::ToolContext const&) /llvm/llvm-project/clang/tools/driver/driver.cpp:391:9
#47 0x000055f306087f85 main /cmake-build-debug/tools/clang/tools/driver/clang-driver.cpp:17:3
#48 0x00007fdc91693d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#49 0x00007fdc91693e40 call_init ./csu/../csu/libc-start.c:128:20
#50 0x00007fdc91693e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#51 0x000055f306053ea5 _start (/cmake-build-debug/clang+++0x5a59ea5)
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
clang version 19.0.0git (https://github.com/llvm/llvm-project.git 919df9d75ac2a721a8072327c803f34486884571)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /cmake-build-debug/bin
Build config: +unoptimized, +assertions
clang++: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++: note: diagnostic msg: /tmp/test-ac25ab.cpp
clang++: note: diagnostic msg: /tmp/test-ac25ab.sh
clang++: note: diagnostic msg:
********************
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsW11T4zjW_jXmRkXKlr8vuDCB9DAv_UI1mV3uKFmWEy225JVkGubXb0m2E8skgQA9VfsxxTRGlo-e8-jo6Bx9ICnpihFy5oTnTnhxglq15uLsO1WoyuSaP57kvHg5WyvVSMfPHLhw4GLFi5xXasbFyoGLPx24WHv80pPf88hxLxw36_-N3O4HO_Bc_5hSqUSLFbgHTtyXAABAKShhBXjitAAl5wbN-Yq1uk0_U0isiHp4IkJSzhyYOBDKJ-JA6MDUCS_0jy5MjdD4om8_vnD88wmWnQC7P2-vL7O7Sy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