[fpc-pascal] What is -CO ?

Martin fpc at mfriebe.de
Fri Jun 9 12:57:49 CEST 2023


On 09/06/2023 12:03, Mattias Gaertner via fpc-pascal wrote:
> Hi,
>
> What is -CO?
>
> In the docs I can only find this sentence:
> "Check for possible overflow of integer operations"
>

Done some testing. -CO produces the below warning.

program Project1;
var a,b: Integer;
var c: integer;
begin
a := Random(9999);
b := Random(9999);
c := a +b;  // project1.lpr(7,3) Warning: Type size mismatch, possible 
loss of data / range check error
writeln(c);
end.


However it overdoes it.

make it
   var a,b: shortInt;

Then the ":=random" will warn => ok.
But the addition still warns, yet it can't ever fail. (even if the 
compiler internally uses int64)


More information about the fpc-pascal mailing list