Compiler: CW HC08 6.0.
Can anyone explain why I get a compiler warning from the following code?
#define SLPRQ 0x02U
CANCTL0 &= (uint8)~SLPRQ; /* "Warning : C705 Possible loss of data". */
If I however #define SLPRQ as 0x02 (signed int), I don't get a warning. I don't understand this. How exactly am I losing data if SLPRQ is unsigned int, but not if it is signed? No matter if it is signed or unsigned, no integer promotions take place: the type is already unsigned int. As the expression is unary, the "usual arithmetic conversions" don't take place either. So how can there be a "possible loss of data" when no implicit conversions exist?
I was assuming this had to do with CANCTL0 being an uint8, and if I change the type of CANCTL0 from uint8 to uint16, the warning indeed disappears. Apparently CW doesn't give a darn about my explicit typecast to uint8.
But... to confuse things further, the warning disappears if I alter the code:
~(unsigned char)SLPRQ;
This yields no warning! Even though integer promotions will silently promote the type to "int". So there is a silent change of signedness, which actually could be a grave bug. But that possible bug yields no warning.
How does any of this make sense?