[fpc-devel] CompareValue

Vincent Snijders vsnijders at quicknet.nl
Sun Mar 4 20:09:05 CET 2007


mftq75 at dsl.pipex.com schreef:
> Quoting Vincent Snijders <vsnijders at quicknet.nl>:
> 
>> C Western schreef:
>>> ð£ÔÒ ëÏÓÁÒÅ×ÓËÉÊ wrote:
>>>>> In the math unit are the CompareValue functions only for signed 
>>>>> integers. Why not for DWORD and QWORD?
>>>> I guess, that it's Delphi mimicing implementation (because it is 
>>>> Delphi-like).
>>>>
>>>> And it can be tricky to distinguish signed and unsigned expression 
>>>> values.
>>>>
>>>> Like,
>>>> a: qword;
>>>> a-1 --- ??? (anyone may know for sure that a-1>0 and want to subtract 
>>>> one)
>>>>
>>>> I guess it's something like that.
>>> If you check <http://www.freepascal.org/mantis/view.php?id=8448> you can 
>>> see this bug in action - the fpcadds and math unit provide signed and 
>>> unsigned versions of CompareValue, but the correct one is not always 
>>> chosen.
>>>
>> What a lousy compiler we use! ;-)
>>
>> Do you have a testprogram, so I can make a fpc bug report?
> 
> I think this is inherent in the language design, as it is too easy to convert
> between signed and unsigned integers. For example should the call:
> 
> CompareValue(0,0)
> 
> use the signed or unsigned version?

But in this particular case, I did not use constants, but variables of 
the same type.

Vincent



More information about the fpc-devel mailing list