I want to be sure I understand what happens if two ints of different width are bitwise OR'ed with eachother. The most sensible option is to left-pad the smaller one with zeroes. I wrote a small program to test this.
Look at this sample code:
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
int main(void)
{
uint32_t foo = 0x00000000;
uint8_t bar = 0xFF;
printf("%"PRIu32"\n", (foo | bar));
printf("%"PRIu32"\n", (bar | foo));
}
If my guess was right, I should expect to get 255 twice. When I run this, I get
255
255
Is this expected and well-defined behavior that it's safe to rely upon? Is there a link explaining all of the behaviors of bit-manipulation with different int widths?