Bug in x86 inline assembly to watch out for

Bug in x86 inline assembly to watch out for

  • Comments 2

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

Leave a Comment
  • Please add 3 and 5 and type the answer here:
  • Post
  • and the path 'f:\rtm\vctools\compiler\utc\src\P2\x86\code.c' in the error message does not seem to be referring to a local file ...

  • No, it refers to a file on the machine that the compiler was built.

Page 1 of 1 (2 items)