The compiler converts values automatically from one type to another to perform some operations (ISO C, §3.2 and ISO C++, §4). These kinds of conversions are called “implicit conversions” because they are not explicitly stated in the source code.
The rules the compiler follows for deciding when to apply implicit conversions sometimes gives results you do not expect. If you enable the Implicit Arithmetic Conversions setting, the compiler issues a warning when it applies implicit conversions:
For example, assigning the value of a variable of type long to a variable of type char results in a warning if you enable this setting.
The compiler also has pragmas that control specific of implicit conversions the compiler warns about (Table 6.1).
This pragma… | Warns about this kind of conversion |
---|---|
warn_illunionmembers | a floating point value to an integer value |
warn_impl_i2f_conv | an integer value to a floating-point value |
warn_impl_s2u_conv | a signed value to an unsigned value |
warn_implicitconv | all; this pragma is equivalent to the Implicit Arithmetic Conversions setting |