clang generating UD2?
Posted: Sun Feb 27, 2011 8:23 pm
I just finished writing a new piece of code, but it crashes only when I enable -O3 -fomit-frame-pointer (I'm using clang as a compiler for x86). I disassembled it to try and find the problem, and what I found was a UD2 instruction halfway through a function. Isn't UD2 only supposed to be used for debugging? Could this perhaps be a compiler bug, or is there some valid purpose for the compiler inserting this instruction in a normal C function? I couldn't figure out exactly where in the C function it was, because the assembly was heavily optimized and the C function contained a large switch statement.
Edit: the UD2 instruction was the faulting instruction, if that wasn't clear.
Edit: the UD2 instruction was the faulting instruction, if that wasn't clear.