while working with bit shifts on the atmega328 chip under avr-gcc 5.4.0 I noticed a bug(?). Let's see some snippets:
This code works as expected:
uint32_t val = 0xaabbccdd;
Serial.println( val, HEX ); //Output: aabbccdd
// For testing 32 bit variables
This one also works:
uint16_t read = 0x3FF;
uint32_t val = read * 65536;
Serial.println( val, HEX ); // Output: 3ff0000
But this is not!:
uint16_t read = 0x3FF;
uint32_t val = read << 16;
Serial.println( val, HEX ); // Output: 0
(With values less than 16 the system even crashes!)
Is there any known bug in the compiler?
Thank you!