[fpc-pascal] 2 bugs ???

Leonardo M. Ramé martinrame at yahoo.com
Wed Sep 7 19:38:53 CEST 2011


From: Yann Bat <batyann811 at gmail.com>
>To: "fpc-pascal at lists.freepascal.org" <fpc-pascal at lists.freepascal.org>
>Sent: Wednesday, September 7, 2011 11:36 AM
>Subject: [fpc-pascal] 2 bugs ???
>
>Hi,
>
>I am trying to learn freepascal generics and I think that I have found 2 bugs.
>
>Tested with FPC 2.4.4 Linux x86
>
>==================
>= BUG 1 - with SizeOf =
>==================
>{--- TGen.Bug ---}
>function TGen.Bug : Integer;
>begin
>  Result := 100000 div SizeOf(_T);  // *** DIVISION BY ZERO ***
>
>  // THE FOLLOWING CODE IS OK !
>  //
>  // var
>  //   S: Integer;
>  // begin
>  //   S := SizeOf(_T);
>  //   Result := 100000 div S;
>end;


The error message is correct, because inside the scope of method  Bug, _T points to nil, and the size of nil is 0, so 10000 div 0 raises the error.

What about using Result := 1000000 div SizeOf(FField); ?

Leonardo.



More information about the fpc-pascal mailing list