[fpc-pascal] QWord/UInt64 and Range Check Errors
inoussa12 at gmail.com
Thu Jun 25 20:58:41 CEST 2009
2009/6/25 Jonas Maebe <jonas.maebe at elis.ugent.be>:
> On 25 Jun 2009, at 20:33, Inoussa OUEDRAOGO wrote:
>> 2009/6/25 Jonas Maebe <jonas.maebe at elis.ugent.be>:
>>> On 25 Jun 2009, at 20:14, Inoussa OUEDRAOGO wrote:
>>>> as it makes one doubtfull about
>>>> the correctness of the program( In my case I debugged the program to
>>>> be sure that the "good" value was assigned).
>>> When it's changed, you will get the warning/error when assigning this
>>> to an int64 and then those cases can be debugged.
>> and that seems more accurate to me
> It's equally accurate. A hex number does not contain any sign information,
> so both interpretations are valid.
so it could be parsed as QWord accurately and assigned to a QWord
(typed) variable without warning, as it is an assignment between two
>>> to an int64 and then those cases can be debugged. It's the same when we
>>> changed from parsing $80000000-$FFFFFFFF as a longint to parsing it as a
>>> cardinal. Suddenly a whole bunch of code no longer worked correctly
>>> then either, and we got a bunch of questions why code no longer compiled
>>> produced warnings.
>> IMHO warnings/errors should be reported as one is actually in a "out
>> of range" case. But if some code depends on this ( such as a bit mask
>> ) changing the behavior of the compiler can effectively be harmfull.
>> I think that should be up to the people (ab)using the parser this way
>> to correct their code by doing a explicit typecast.
> There is no abuse of the parser. The parser has, since the very first moment
> that int64 and qword were supported in FPC, always parsed such numbers as
> int64. So people using it like that, are using it as designed. In fact,
> before Delphi supported uint64, it also parsed such values as int64.
Just to clear out things :
* I am not for a blind compatibility with Delphi
* I am not a compiler dev guy, so I could be dead wrong
* I do want to understand the basics, the fondaments of such a
decision ( to parsed as Int64 )
More information about the fpc-pascal