Jonas Maebe wrote:

Actually, it won't help because "qword - 1" will still be evaluated as
qword. The issue is that there is no safe way to evaluate this with
range checking that is correct in all cases without a 128 bit integer type:
1) if you evaluate it as qword, you get a range error if count is 0 (as
above)
2) if you evaluate it as int64, then if count is high(int64)+1 you will
get a range error even though the result could be represented in int64

Without type inclusion, that is in a language that allows mixing typed an untyped numbers, there is no anambiguous solution, as Jonas points out. So, I suggest to choose the next best solution, which is to let result type of the expression decide whether to apply 1) or 2). In this case, it would be 2) as the result type is signed.

Regards,

Adriaan van Os

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to