I can usually understand the reason behind a compiler warning, but this one seems just plain wrong.
#include <stdint.h>
uint8_t myfunc(uint8_t x,uint8_t y)
{
x |= y;
return x;
}
The intel compiler with -Wall complains:
conversion from "int" to "uint8_t={unsigned char}" may lose significant bits
x |= y;
^
Is this right? Is the above code non-portable and non-standard somehow?
That’s
integer promotionsat work.in
both operands of the
|operator are promoted tointthen the result is converted back to
uint8_tlosing precision.