[fpc-pascal] Assign int64 to int32 shows no warnings at compilation time
Jonas Maebe
jonas at freepascal.org
Tue Dec 18 18:52:48 CET 2018
On 18/12/18 18:27, Graeme Geldenhuys wrote:
> Just as a comparison, here is the same code, but in Java.
>
> ===========================================
> public class Overflow {
>
> public static void main(String[] args) {
>
> int d32;
> long d64;
>
> d32 = Long.MAX_VALUE;
>
> System.out.println(d32);
> System.out.println(d64);
>
> }
>
> }
> ==========================================
You are assigning an int64 constant to a 32 bit variable here. In your
Pascal program, you are assigning a 64 bit *variable* to a 32 bit variable.
If you compile the equivalent Pascal program, you will always get a
warning, and you will get an error if you compile with range checks.
Jonas
More information about the fpc-pascal
mailing list