<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/126940>126940</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
#embed assertion fail if a known parameter comes after an unknown
</td>
</tr>
<tr>
<th>Labels</th>
<td>
c23,
crash-on-invalid,
embed
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Fznamznon
</td>
</tr>
</table>
<pre>
Reproducer
```
int a[] = {
#embed __FILE__ bla(2) limit(2)
};
```
Backtrace
```
clang: /root/llvm-project/clang/lib/Lex/PPDirectives.cpp:3980: void clang::Preprocessor::HandleEmbedDirective(clang::SourceLocation, clang::Token&, const clang::FileEntry*): Assertion `(Params || CurTok.is(tok::eod)) && "expected success or to be at the end of the directive"' failed.
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 -fverbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c23 -E <source>
#0 0x0000000003e753a8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e753a8)
#1 0x0000000003e73064 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e73064)
#2 0x0000000003dbf538 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x000073e5d9842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x000073e5d98969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x000073e5d9842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x000073e5d98287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x000073e5d982871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x000073e5d9839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x0000000007c0a06b clang::Preprocessor::HandleEmbedDirective(clang::SourceLocation, clang::Token&, clang::FileEntry const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x7c0a06b)
#10 0x0000000007c17f97 clang::Preprocessor::HandleDirective(clang::Token&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x7c17f97)
#11 0x0000000007bc818a clang::Lexer::LexTokenInternal(clang::Token&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x7bc818a)
#12 0x0000000007bca34f clang::Lexer::Lex(clang::Token&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x7bca34f)
#13 0x0000000007c5b96c clang::Preprocessor::Lex(clang::Token&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x7c5b96c)
#14 0x0000000004b1baf1 clang::DoPrintPreprocessedInput(clang::Preprocessor&, llvm::raw_ostream*, clang::PreprocessorOutputOptions const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4b1baf1)
#15 0x0000000004aeddee clang::PrintPreprocessedAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4aeddee)
#16 0x0000000004ad37a5 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4ad37a5)
#17 0x0000000004a5715e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4a5715e)
#18 0x0000000004bc205e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4bc205e)
#19 0x0000000000d4c48f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd4c48f)
#20 0x0000000000d43f0a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#21 0x0000000004853569 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
#22 0x0000000003dbf9e4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3dbf9e4)
#23 0x0000000004853b5f 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
#24 0x0000000004816cdd clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4816cdd)
#25 0x0000000004817d5e 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+0x4817d5e)
#26 0x000000000481fd15 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x481fd15)
#27 0x0000000000d49283 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd49283)
#28 0x0000000000c122c4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc122c4)
#29 0x000073e5d9829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#30 0x000073e5d9829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#31 0x0000000000d439b5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd439b5)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
The diagnostic also points to the next parameter after wrong one
```
<source>:2:24: error: unknown embed preprocessor parameter 'bla'
2 | #embed __FILE__ bla(2) clang::offset(3) limit(2)
|
```
Godbolt https://godbolt.org/z/8oWh41vb6
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzkWUtv2z4S_zTMhZAhkXoefFCdeLdFgAZNsXs0KIqyuZFIgaRcp59-QUq2Ho2zza63l39QFxIfw9_8ZjgzFInWfC8YW4PoE4ju70hnDlKttz8FaX4KKe4KWb6uv7FWybKjTAE_B7E__PNzLgwk_VQI8D0EySc7AmHWFKyEu9328-PDbgeLmgCUIoAyWPOGm-HFjk3uAf60EAv8_BOhL0YRyhZdtCZiD3AOAdoqKQ1A27o-Nl6r5L8Yta_9CLSteQHQ9pGdANo-Pd1zxajhR6ZXtG0BznGW-lbOUfISnqUCnD8pqyxlWkvVt_ydiLJmD1ajixSA0smcZ9kpyh4lJYZLAdBmKvC7fGECoNg1S6HNtHPLa_YgjHoFKLeE4BzmWjNl5UCrMUqfiCKNhiDZgGQDN536Ll9WXAOUGvnSS2GytJNRBt06MQQIsVPLqGEl1B212kCpoJGwYJAYaA4MMlFCWbnHclQLAZTAivCalSvg50-PD_nzA9Rd0XADCSy6PVSslcpYYQdjWm0hoC1A2z03h65YUdkMRvnVNlzrjmmAtpCIEnJB665kDgJVRB9gcbE62sD2YgmrhaPYNtuZRGtJObHqqU5ATRVvjcX7bAh9gWXXWBMDP_dXwM-elNwr0kCi9l3DhNGD_8jW-YtsWl4z5bFTW0vF1NmHPHK2hPaM6sQLQNuCi3M39PblD6IqL4TeHnrSSiRta-V2pu3MSkOvOjJVSM08ohvoPUPP21PqGSlreiBcAHz_Lgw7WAvS6oM00KuorKXySk72QmrDqV1ASM9RN2_WpgT4niIMvQcI8GZgDz8A32qOfeif_PMfZkmESQqdyZw_6Vd93gxcGMfp994q6ThIkR87qY1ipBm8mwvT-2D6P5ML0Cf_NADrA4WFHSxgYz8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