Table of Contents Previous topic Next topic
C COMPILER->Compiler Command Line Options->Suppress Integral Promotion (/Op)
The /Op option instructs the compiler to suppress integral promotion.
Normally, unless where a loss of precision can be guaranteed not to occur, the compiler will convert the value of all identifiers which have a size smaller than int to int before including the value in an expression. (This is the normal ANSI requirement.) If this conversion is suppressed, the compiler can generate more efficient code.
However, depending on the values of the identifiers in the expression, the suppression of integral promotion can result in a loss of precision. For instance consider the following expression:
unsigned char a, b, c, d;
a = (b + c) / d;
If the sum of b and c is greater than 255, then with integeral promotion suppressed, the high byte of the result will be lost. If d is greater than 1, the resulting value of a will therefore be different to when integral promotion is not suppressed.
Note that if any a, b, c or d were for instance int, then integral promotion would still occur even if integral promotion was being suppressed. So if, in the above example, a was int there would be no loss of precision whatever the values of b and c.
Integral promotion can be enabled and disabled locally using the optimize pragma.