[fpc-pascal] Assign int64 to int32 shows no warnings at compilation time

Graeme Geldenhuys mailinglists at geldenhuys.co.uk
Tue Dec 18 18:27:02 CET 2018

On 18/12/2018 17:13, Graeme Geldenhuys wrote:
> Is there a FPC command line parameter to enable warnings or errors for
> the following situation at compile time? All logic tells me that
> detecting this an runtime only is WAY to late in the game!

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;




$ javac Overflow.java
Overflow.java:8: error: incompatible types: possible lossy conversion
from long to int
        d32 = Long.MAX_VALUE;
1 error

The error is raised at compile time, which seems a LOT more logical to
me. After all, we don't want our programs to crash on site at a client -
then we look bad. :-/ I'd rather fix the code long before the client
sees it. ;-)


fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal

My public PGP key:  http://tinyurl.com/graeme-pgp

More information about the fpc-pascal mailing list