Implementation-defined behavior occurs when the C standard permits alternatives and the implementation chooses and documents one. The choice is valid for that implementation, but code depending on it is not portable. section 5.2
Signedness of char
The base type char may behave like either signed or unsigned, depending on the platform. Consequently, code that relies on the range or signedness of char can behave differently across implementations. section 5.2
Implementation-defined choices appear in several related situations:
- The C standard constrains, but does not prescribe, the precision of its unpromoted integer types; their properties depend on implementation-defined factors. section 5.2
- Types such as int and long may have identical value sets while remaining distinct types. section 5.2
- Converting UINT_MAX to a signed integer type has an implementation-defined result: an implementation may preserve the bit pattern or stop execution. section 15.1.2
Implementation-defined does not mean universally portable. Treat implementation-defined conversions that cannot represent the source value as erroneous, even though each implementation defines its own behavior. section 15.1.2
Table 5.1 Base types according to the four main type classes. Types with a gray background don’t allow for arithmetic; they are promoted before doing arithmetic. Type char is special since it can behave like unsigned or signed, depending on the platform. All types in this table are considered to be distinct types, even if they have the same class and precision.
| Class | Systematic name | Other name | Rank | |
|---|---|---|---|---|
| Integers | Unsigned | bool | _Bool | 0 |
unsigned char | 1 | |||
unsigned short | 2 | |||
unsigned int | unsigned | 3 | ||
unsigned long | 4 | |||
unsigned long long | 5 | |||
| [Un]signed | char | 1 | ||
| Signed | signed char | 1 | ||
signed short | short | 2 | ||
signed int | signed or int | 3 | ||
signed long | long | 4 | ||
signed long long | long long | 5 | ||
| Floating point | Real | float | ||
double | ||||
long double | ||||
| Complex | float _Complex | float complex | ||
double _Complex | double complex | |||
long double _Complex | long double complex | |||
Use the base-type table to compare distinct C types and identify char's implementation-dependent signedness. section 5.2

