<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/111463>111463</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang++][crash on valid] no address_space attribute found at the expected location!
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
yijan4845
</td>
</tr>
</table>
<pre>
**This testcase is generated by a fuzzer.**
Compiler Explorer: [https://godbolt.org/z/j51Wj7c6a](https://godbolt.org/z/j51Wj7c6a)
This valid code will crash on both Clang Trunk and Clang Assertion Trunk:
```cpp
template <int I>
void func() {
int *y __attribute__((address_space(I)));
}
```
Stack dump:
```
no address_space attribute found at the expected location!
UNREACHABLE executed at /root/llvm-project/clang/lib/Sema/SemaType.cpp:6273!
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: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics <source>
1. <source>:3:43: current parser token ';'
2. <source>:2:13: parsing function body 'func'
3. <source>:2:13: in compound statement ('{}')
#0 0x0000000003b99db8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b99db8)
#1 0x0000000003b97a7c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b97a7c)
#2 0x0000000003ae6288 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x000071cafea42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x000071cafea969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x000071cafea42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x000071cafea287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x0000000003af1b5a (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3af1b5a)
#8 0x000000000749bdb7 GetFullTypeForDeclarator((anonymous namespace)::TypeProcessingState&, clang::QualType, clang::TypeSourceInfo*) SemaType.cpp:0:0
#9 0x000000000749c4cf clang::Sema::GetTypeForDeclarator(clang::Declarator&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x749c4cf)
#10 0x00000000069ed9ab clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69ed9ab)
#11 0x00000000069eec30 clang::Sema::ActOnDeclarator(clang::Scope*, clang::Declarator&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69eec30)
#12 0x00000000066515de clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66515de)
#13 0x0000000006661059 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6661059)
#14 0x0000000006669977 clang::Parser::ParseSimpleDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, bool, clang::Parser::ForRangeInit*, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6669977)
#15 0x0000000006669e39 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6669e39)
#16 0x00000000067161d2 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x67161d2)
#17 0x0000000006716f00 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6716f00)
#18 0x0000000006717dd5 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6717dd5)
#19 0x000000000671952a clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x671952a)
#20 0x000000000662c633 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x662c633)
#21 0x0000000006661a3d clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6661a3d)
#22 0x000000000672aec6 clang::Parser::ParseDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x672aec6)
#23 0x00000000067387fc clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (.part.0) ParseTemplate.cpp:0:0
#24 0x0000000006738b1a clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6738b1a)
#25 0x0000000006669fe3 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6669fe3)
#26 0x0000000006628317 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6628317)
#27 0x00000000066291bd clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66291bd)
#28 0x0000000006629660 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6629660)
#29 0x000000000661b6a2 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x661b6a2)
#30 0x00000000044f0a28 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44f0a28)
#31 0x00000000047aa379 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47aa379)
#32 0x0000000004728cbe clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4728cbe)
#33 0x000000000488fbfe clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x488fbfe)
#34 0x0000000000cd801f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcd801f)
#35 0x0000000000ccfd2a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#36 0x00000000045346f9 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::'lambda'()>(long) Job.cpp:0:0
#37 0x0000000003ae6734 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ae6734)
#38 0x0000000004534cef clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#39 0x00000000044fa62d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44fa62d)
#40 0x00000000044fb71d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44fb71d)
#41 0x0000000004503045 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4503045)
#42 0x0000000000cd4eef clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcd4eef)
#43 0x0000000000ba49a4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xba49a4)
#44 0x000071cafea29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#45 0x000071cafea29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#46 0x0000000000ccf7de _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xccf7de)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsW19z4ygS_zTKC2WXBLL-PORBceLZbGVvcuPc7aMLIWQzI4MOUMaZT38FyIlQHGcyG89u3e3W7IyNoPn1r5vuBmGsFFtzSs-D2UUwuzzDnd4Ief7APmMeZ_HsrBTVw3kAiwAWdxumgKZKE6woYAqsKacSa1qB8gFgUHffvlE5dZ2D8DII-7_nYtuyhkpwtWsbIakMUAGC2cVG61YFqAjgIoCLtahK0eipkOsALr4FcPF5Fv3-OSUJDmaXAcy-vzvMh9Nb3Pe4YRUgoqLgK2saQCRWGyA4KIXegHmD-RrcyY5_AZhX_fdCKSo1E9w9MVM7sUno_pC2dS2abtsGawoCNGdcg-sAXbkn94JVoO44CWAWwBwE6YV7AIDpGMDiAaxWWGvJyk7T1cr2y3BVSarUSrWY0ABm10Yn9wf1AoL0cgRnqPRSY_IFVN22fQ7bfeUCeLOARxCgFh2vANZAbyigu5YSY-RGEGzYCGDkJPzrH5-uivkvxcXNFaA7SjrTCxulFlIIHcBF09xvJ60UnykxX4mh1TSzMoCLJd3i_p-7h5ZODZuoSGCKHme4vbkqlldAdeWWaYBB2a2BpK2QGmgBRg7B9KYrp0Rs-4mfz8-U6qgK4MIamXHSdBW1Sjp3KDH5oqVlfA5aSVspCFWKVkCJTrpmMxIrJQizni87DhSRrNXTF4kPp0GY30qxlngLsFx3W8q1sosALkRrmemXyITul0jP1gTvnVBNtPVCuCgZfyLzIoAXYLKuvmJZT2IwWYOJMHJx2xrpnW47PVVgsjVcgMlklyUTrLYT9cA13gXoknFNGzCpuZjcU1kKRc1zMFmCyWRNyEQL0ZANZjxAl0fxms6K41ZthAaTmohGyEnF8JoLpRlRbg7LtNccoHlP737RRIYwrxkVKEBFbP4CpJOScg1aLBWVQIsvlIMApmZlwNRJgAckwAA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