...
- Integer operands of any pointer arithmetic, including array indexing;
- The assignment expression for the declaration of a variable length array;
- The postfix expression preceding square brackets
[]or the expression in square brackets[]of a subscripted designation of an element of an array object; and - Function arguments of type
size_torrsize_t(for example, an argument to a memory allocation function).
This rule also applied applies to arguments passed to library functions such as memset(), memchr(), strchr() that are truncated by the function.the following library functions that are converted to unsigned char:
memset()memset_s()fprintf()and related functions. For the length modifierc, if nollength modifier is present, theintargument is converted to anunsigned char, and the resulting character is written.fputc()ungetc()memchr()
And to arguments to the following library functions that are converted to char:
strchr()strrchr()
The only integer type conversions that are guaranteed to be safe for all data values and all possible conforming implementations are conversions of an integral value to a wider type of the same signedness. The C Standard, 6.3.1.3 [ISO/IEC 9899:2011], says,
...