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

Martin Frb lazarus at mfriebe.de
Tue May 19 13:17:19 CEST 2015

On 19/05/2015 11:03, Adriaan van Os wrote:
>> the cpu, so if you want to guarantee consistent behaviour on all 
>> platforms, you can no longer just emit a shift left/right instruction 
>> and have to add all kinds of checks.
>> Maybe we should support emitting range checks for the right operand 
>> though (to give an error if it falls outside the range of shift 
>> values whose behaviour is defined).
> The right operand of a bitwise shift is a count, a real-world number 
> of bits. A negative number doesn' t make sense and must regarded as an 
> error. So yes, emitting range checking is the right idea. We should do 
> better in Pascal than in C .....

True, if range checks are enabled, otherwise see my other mail

More information about the fpc-devel mailing list