Microchip Technology XC8 Standard Compiler (Workstation) SW006021-1 SW006021-1 User Manual

Product codes
SW006021-1
Page of 518
Error and Warning Messages
 2012 Microchip Technology Inc.
DS52053B-page 435
MESSAGES 750-999
(750) constant operand to || or && 
(Code Generator)
One operand to the logical operators || or && is a constant. Check the expression for 
missing or badly placed parentheses. This message may also occur if the global opti-
mizer is enabled and one of the operands is an auto or static local variable whose 
value has been tracked by the code generator, for example:
{
int a;
a = 6;
if(a || b)  /* a is 6, therefore this is always true */
    b++;
(751) arithmetic overflow in constant expression 
(Code Generator)
A constant expression has been evaluated by the code generator that has resulted in 
a value that is too big for the type of the expression. The most common code to trigger 
this warning is assignments to signed data types. For example:
signed char c;
c = 0xFF;
As a signed 8-bit quantity, c can only be assigned values -128 to 127. The constant 
is equal to 255 and is outside this range. If you mean to set all bits in this variable, then 
use either of:
c = ~0x0;
c = -1;
which sets all the bits in the variable, regardless of variable size, and without warning.
This warning can also be triggered by intermediate values overflowing. For example:
unsigned int i;  /* assume ints are 16 bits wide */
i = 240 * 137;   /* this should be okay, right? */
A quick check with your calculator reveals that 240 * 137 is 32880 which can easily be 
stored in an unsigned int, but a warning is produced. Why? Because 240 and 137 
and both signed int values. Therefore the result of the multiplication must also be 
a signed int value, but a signed int cannot hold the value 32880. (Both operands 
are constant values so the code generator can evaluate this expression at compile 
time, but it must do so following all the ANSI C rules.) The following code forces the 
multiplication to be performed with an unsigned result:
i = 240u * 137;  /* force at least one operand
                    to be unsigned */
(752) conversion to shorter data type 
(Code Generator)
Truncation may occur in this expression as the lvalue is of shorter type than the 
rvalue
, for example:
char a;
int b, c;
a = b + c;  /* int to char conversion
               may result in truncation */
(753) undefined shift (* bits) 
(Code Generator)
An attempt has been made to shift a value by a number of bits equal to or greater than 
the number of bits in the data type. This will produce an undefined result on many pro-
cessors. This is non-portable code and is flagged as having undefined results by the C 
Standard, for example:
int input;
input <<= 33;  /* oops -- that shifts the entire value out */