Re: [fpc-pascal] Strange "division by zero" error using variants

2022-05-24 Thread Michalis Kamburelis via fpc-pascal
That's a funny interaction between Variants and Pascal's ambiguous (logical or bitwise) "and" :) Both the operators and the types are ambiguous -> making the boolean short-circuit evaluation not possible. Indeed one workaround is to cast the variants to Booleans explicitly, which makes it use logi

Re: [fpc-pascal] Strange "division by zero" error using variants

2022-05-24 Thread Florian Klämpfl via fpc-pascal
Am 24.05.22 um 19:28 schrieb Thomas Kurz via fpc-pascal: 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 =

[fpc-pascal] Strange "division by zero" error using variants

2022-05-24 Thread Thomas Kurz via fpc-pascal
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