Compiler Warning (level 4) C4242
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 4) C4242

Error Message

'identifier' : conversion from 'type1' to 'type2', possible loss of data

The types are different. Type conversion may result in loss of data. The compiler makes the type conversion.

This warning is off by default. See Compiler Warnings That Are Off by Default for more information.

For additional information on C4242, see Common Compiler Errors.

The following sample generates C4242:

// C4242.cpp
// compile with: /W4
#pragma warning(4:4242)
int func() {
   return 0;

int main() {
   char a;
   a = func();   // C4242, return type and variable type do not match
© 2016 Microsoft