Tech & AI News
Hacker News

Why is the x86 undefined instruction called ud2? Why 2?

The ud2 instruction is an architecturally defined undefined opcode that always raises an “invalid opcode” exception, and compilers use it to mark unreachable code such as after a [[noreturn]] call. Intel introduced it after earlier unofficial byte sequences 0F FF (ud0) and 0F B9 (ud1) became unreliable on newer CPUs. ud2 is a two-byte opcode with no operands, avoiding the decoding side effects that caused page-fault inconsistencies with the earlier variants.