[fpc-devel] bitwise shift oddity a << b

Jonas Maebe jonas.maebe at elis.ugent.be
Tue May 19 15:00:35 CEST 2015


Adriaan van Os wrote on Tue, 19 May 2015:

> Section 6.5.7. But in that standard the behaviour is undefined also  
> when "the value of the right operand is greater than or equal to the  
> width of the promoted left operand", which I think is a bit too  
> simplistic (since, if we start talking about the maximum number of  
> bits that can "legally" be shifted, then that number depends on the  
> actual value of the left operand,

No, it does not. It only depends on the type. Shifting an uint32_t  
with value 1 right by 32 bits is undefined. Shifting an uint64_t with  
value 1 right by 32 bits is 0.


Jonas



More information about the fpc-devel mailing list