@Jonas, Thanks,it works well. Turn on the range checking switch {$R+},the free pascal compiler would also seek for compile-time range error.For example,the follow line will not compile through:
byteVal := 256; It will produce 'Error: range check error while evaluating constants'; In conclusion,free pascal do provide mechanism to detect type-catagory-inside check,even thought IMHO,it's not perfect. jcyang. On Fri, Jan 15, 2010 at 1:02 AM, Jonas Maebe <jonas.ma...@elis.ugent.be>wrote: > > On 14 Jan 2010, at 16:30, Jichao Yang <jcyan...@gmail.com> wrote: > > int64Val := 2147483648; { 2^32 } >> intVal := int64Val; { does not trigger any warnings } >> > > Assigning a longint to a byte does not generate a warning either. This is > simply how Pascal works. If you want compile-time checks for such > operations, use a language such as Ada instead. > > > Now the intVal should be 0 which is not what I wanted >> > > Enable range checking, and you will get a run time error. > > > Jonas > _______________________________________________ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/mailman/listinfo/fpc-pascal >
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal