Yesterday I discovered I wasn’t doing proper range checking for ordinal 
constants so for example, a generic with “const U: byte” could be specialized 
as <1000>. We want ordinal constants to respect range checks right?

I made a little utility function which works in most cases but I don’t think 
it’s correct and more importantly this function probably already exists in the 
compiler.

    function compare_orddef_by_range(param1,param2:torddef): boolean;
      var
        orddef1,orddef2:tdef;
      begin
         range_to_type(param1.low,param1.high,orddef1);
         range_to_type(param2.low,param2.high,orddef2);
         result:=compare_defs(orddef1,orddef2,nothingn)>=te_convert_l1;
      end;


Is there an existing function for this or a better way to do it?

Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to