Compiler Warning (Level 1) C4731
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

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) {
      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.

© 2016 Microsoft