C2705: Possible loss of data

[WARNING]

Description

The compiler generates this message if a constant is used which exceeds the value for a type. Another reason for this message is if a object (e.g. long) is assigned to an object with smaller size (e.g. char). Another example is to pass an actual argument too large for a given formal argument, e.g. passing a 32bit value to a function which expects a 8bit value.

Example
  signed char ch = 128; // char holds only -128..127

  
  char c;

  
  long L;

  
  void foo(short);

  
  void main(void) {

  
    c = L; // possible lost of data

  
    foo(L); // possible lost of data

  
  }

  
Tips

Usually this is a programming error.

See also