Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

A loss of data (truncation) can occur when converting from a value of a signed integer type to a value of a signed type with less precision. This noncompliant code example results in a truncation error on most implementations:

Code Block
bgColor#FFcccc
langc
#include <limits.h>

void func(void) {
  signed long int s_a = LONG_MAX;
  signed char sc = (signed char)s_a; /* Cast eliminates warning */
  /* ... */
}

...