From: Yann Bat <batyann...@gmail.com> >To: "fpc-pascal@lists.freepascal.org" <fpc-pascal@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. _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal