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.
clang generating UD2?
- NickJohnson
- Member
- Posts: 1249
- Joined: Tue Mar 24, 2009 8:11 pm
- Location: Sunnyvale, California
Re: clang generating UD2?
There's an undefined behavior in your code, you may consider yourself lucky not to meet the nasal demons.