Some compilers (like gcc) emit an 'ud' instruction (https://www.felixcloutier.com/x86/ud) in some situations where the compiler detects undefined behaviour. IIRC this instruction triggers SIGILL on Linux.
I ran into this a few days ago when I was running some else's old code that didn't return a value at the end of a method expecting a return value in C. The program would crash with a core dump and the debugger wasn't very clear either. It's been a while since I've needed to dig into the disassembly view.
I don't understand why the compiler wouldn't just error out if it generates code that will never actually succeed, but I'm sure there's some C programmer's explanation for it.
I'm a C programmer and I don't understand it either to be honest. The compiler obviously knows that it encounters UB in this case because it specifically inserts an ud instruction.
It could at least warn about it (and if it doesn't have the information to generate a useful warning or error at that point where the ud instruction is inserted, then that's obviously a problem that needs fixing).