Peter Vreman wrote: > > IMO the compiler can convert between Inc and Dec, for negative > > constants, so that the value always is positive, compatible with > > signed and unsigned data types. > > That means different behaviour between the use of a variable or constant. > That is something you never want.
Why not? I expect that the compiler evaluates constant expressions, and creates the best code for the resulting values. >>> So, if x is a Longword and if SomeConstant equals >>> -1, either it adds $ffffffff (and there will be an overflow >>> if x > 0) or it stops at compile time saying that -1 is not >>> a Longword. In the case of Inc(x, SomeConstant) the value of the named constant can be changed, with arbitrary positive or negative values. Would you then want to find all uses of "someconst" in your code, to find out where your code deserves a modification? IMO every calculation, that can result in illegal results in *normal* operation, has to be handled appropriately in the code. If no problems are predicted, expected, and handled, in explicit code, the compiler only has to care about coding errors, that result in *unexpected* overflows. I don't think that a calculation should produce or not produce an overflow, depending only on the sign of the given value. From the mathematical viewpoint +(+1) and -(-1) is perfectly equivalent, as is +(-1) and -(+1). When there exist reasons why such expressions should be handled differently, the user is responsible for indicating such an exceptional situation. DoDi _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel