Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Compiler Warning (Level 1) C4731
Collapse the table of content
Expand the table of content

Compiler Warning (Level 1) C4731

Error Message

'pointer' : frame pointer register 'register' modified by inline assembly code

A frame pointer register was modified. You must save and restore the register in your inline assembly block or frame variable (local or parameter, depending on the register modified), or your code may not work properly.

The following sample generates C4731:

// C4731.cpp
// compile with: /W1 /LD
// processor: x86
// C4731 expected
void bad(int p) {
   __asm
   {
      mov ebp, 1
   }

   if (p == 1)
   {
      // ...
   }
}

EBP is the frame pointer (FPO is disallowed) and it is being modified. When p is later referenced, it is referenced relative to EBP. But EBP has been overwritten by the code, so the program will not work properly and may even fault.

Community Additions

ADD
Show:
© 2015 Microsoft