<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/149372>149372</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang assertion failure "Assertion `&RO == Options.end() - 1 && "Default or Generic case must be last"' failed."
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
bi6c
</td>
</tr>
</table>
<pre>
Compiler Explorer: https://godbolt.org/z/jM6K8rd56
- clang start crashing on 19.1.0
- generated by fuzzer
Console:
```console
clang++: /root/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:2943: void clang::CodeGen::CodeGenFunction::EmitX86MultiVersionResolver(llvm::Function*, llvm::ArrayRef<clang::CodeGen::CodeGenFunction::MultiVersionResolverOption>): Assertion `&RO == Options.end() - 1 && "Default or Generic case must be last"' 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-19.1.0/bin/clang++ -gdwarf-4 -g -o /app/output.s -fno-verbose-asm -c --gcc-toolchain=/opt/compiler-explorer/gcc-14.2.0 -fcolor-diagnostics -fno-crash-diagnostics -O2 <source>
1. <eof> parser at end of file
2. Per-file LLVM IR generation
#0 0x0000000003ae9978 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x3ae9978)
#1 0x0000000003ae766c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x3ae766c)
#2 0x0000000003a308f8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007238db642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007238db6969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x00007238db642476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007238db6287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x00007238db62871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x00007238db639e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x0000000003ebbc81 (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x3ebbc81)
#10 0x0000000003f35175 clang::CodeGen::CodeGenModule::emitMultiVersionFunctions() (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x3f35175)
#11 0x0000000003f37039 clang::CodeGen::CodeGenModule::Release() (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x3f37039)
#12 0x00000000043fb06e (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) ModuleBuilder.cpp:0:0
#13 0x00000000043f8cb5 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x43f8cb5)
#14 0x00000000064cc55c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x64cc55c)
#15 0x00000000043f9448 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x43f9448)
#16 0x0000000004684f59 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x4684f59)
#17 0x0000000004609f8e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x4609f8e)
#18 0x000000000476e2be clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x476e2be)
#19 0x0000000000c82b7f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0xc82b7f)
#20 0x0000000000c7bcda ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#21 0x000000000443cba9 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 0x0000000003a30da4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x3a30da4)
#23 0x000000000443d19f 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 0x0000000004402c05 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x4402c05)
#25 0x000000000440366d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x440366d)
#26 0x000000000440b075 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x440b075)
#27 0x0000000000c7fe95 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0xc7fe95)
#28 0x0000000000b547a4 main (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0xb547a4)
#29 0x00007238db629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#30 0x00007238db629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#31 0x0000000000c7b78e _start (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0xc7b78e)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
code:
```c
enum { VALUE = 3 };
extern int glob_x;
int __attribute__((target_clones("default,avx"))) f(int x) { return x + glob_x + VALUE; }
int f(int);
int __attribute__((target_clones("default,avx"))) f(int);
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzkWd9v2zgS_muYl4EMiZL148EPihPv7V6LFk23uDeDoiiHW4kUSCrr7F9_IClbkpP0NoukL1e4iE2Rw2---TjkiERrfhCMbdD6Gq1vrshg7qXaVDylV5WsHzdb2fW8ZQpuj30rFVMoLuHemF6juER4h_DuIOtKtmYl1QHh3V8I7_74mP47V_U6RWEZAG2JOIA2RBmgiuh7Lg4gBUTFKlqFrsuBCaaIYTVUj9AMf_3FFApLFJZbKbRsmZ0rLFEa-g8dW8PS2Ub42n7iEhDeKSkNwru2feiCXsk_GLU_x367llcI77ayZr8wMX3bDYIaLsWK9j2KS1wksTX3IHnt4VsAcXkaN_9xGuobbztu_pOnH4fW8G9MaS7FF6Zl-8AUwrkF5fudR-ES4S1MD0qlyOMX1qB4-6qJn5vxU--f3yJcWHdKrZmyTWBpxOmXT4DiGxTfgO-pV0zUCOcIFxBABAinCKeAML5hDRlaA1LBLzZUnAIlmkE3aAMVg5ZogzBGOIOG8JbVKxSWnz_clne3oIeq4wYIVMMBFOulMmDkpYa4uR-qFZXdGLunIeRaD0wjvAMiauCCtkPNwNwzLyqoCP1uFKHMEtor1itJmdasBi0H5ZvtSKK1pNyJTQ0CNFW8NxbvnSH0O9RD13u5hSsUFp-VPCjSAVGHoWPC6FFmsneyGldHwE6rY5RaQE5c62DUOd5VXExStJKF4FD_SVQTJBAcIJDWMOl7a34w_WBWGoJGyOCBqUpqFhDdQUAhCA6UBkbKlt4TLmwMfwTIdo6SFV6FEDRUtlIFNScHIbXhdJzBUbhs_oQBxduRu_gWhWVkCUHxlskGxbfQE6WZAmKAiRpkAw13axI73pgK7G_48OHbR_j1y2mJ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