Tuesday, October 17, 2006 1:53 PM
Kevin Frei
Bug in x86 inline assembly to watch out for
Imagine this very lame code:
int main() {}
void BugAsm()
{
__asm {
MOV [ESP+12],OFFSET main
}
}
void(*BugAsmPt)()=&BugAsm; // this is just to make sure the function is not removed by /OPT:REF
Now imagine your significantly less lame code doing something similar.
Now imagine that the compiler crashes with a bizzare message about "x86\code.c" something or other.
Well, you can fix this problem by changing the assembly code to this:
mov DWORD PTR[esp+12], OFFSET main
Another unfixed bug, worked around :-|
-Kev