Dear all,
please consider the following code:
program Project1;
{$booleval off}
var
v1, v2: variant;
a: boolean;
b: integer;
begin
a := true;
b := 0;
// this works as expected:
if a and (b > 0) and ((0+1) mod b = 0) then Writeln ('ok');
v1 := true;
v2 := 0;
// this gives a "division by zero":
if v1 and (v2 > 0) and ((0+1) mod v2 = 0) then Writeln ('ok');
end.
The "variant" variant results in a "division by zero". Obviously, it tries to
evaluate the modulo-expression even though this shouldn't happen because
complete boolean evaluation is disabled and the "if"-result is already known to
be false after checking "v2>0".
Can anyone explain this strange behavior?
Kind regards,
Thomas
_______________________________________________
fpc-pascal maillist - [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal