Skip to content

Latest commit

 

History

History
30 lines (24 loc) · 805 Bytes

compiler-warning-level-1-c4739.md

File metadata and controls

30 lines (24 loc) · 805 Bytes
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: Compiler Warning (Level 1) C4739
Compiler Warning (Level 1) C4739
11/04/2016
C4739
C4739
600873b3-7c85-4cd4-944e-cd8e01bfcbb0

Compiler Warning (Level 1) C4739

reference to variable 'var' exceeds its storage space

A value was assigned to a variable, but the value is greater than the size of the variable. Memory will be written beyond the variable's memory location, and data loss is possible.

To resolve this warning, only assign a value to a variable whose size can accommodate the value.

The following sample generates C4739:

// C4739.cpp
// compile with: /RTCs /Zi /W1 /c
char *pc;
int main() {
   char c;
   *(int *)&c = 1;   // C4739

   // OK
   *(char *)&c = 1;
}