[fpc-devel] Abs(Variant) unexpected result

Bart bartjunk64 at gmail.com
Sun Feb 25 17:11:27 CET 2018


On Sun, Feb 25, 2018 at 5:01 PM, Jonas Maebe <jonas at freepascal.org> wrote:

> As Michael said, overloads are selected at compile time. This is true for
> both FPC and Delphi. We even have over a 100 unit tests that we ran under
> Delphi to reverse engineer their selection priorities in case of variants:
> https://svn.freepascal.org/svn/fpc/trunk/tests/test/cg/variants/
>
> Abs(), however, gets a forced conversion to float in Delphi:
> https://bugs.freepascal.org/view.php?id=20551

Hmm, did not find that one (I searched bugtracker before posting here).


Seems you are right:

Delphi Tokyo 10.2

X = -1
VarIsFloat : FALSE
VarIsNumeric: TRUE
VarIsOrdinal: TRUE
After Abs()
X = 1
VarIsFloat : TRUE
VarIsNumeric: TRUE
VarIsOrdinal: FALSE

So, would it be possible to have an overloaded Abs(V: Variant):
Variant; function in the variants unit?

To be clear. Personally I don't need it (at least not ATM), I'm just curious.

Thanks for explaining.

Bart

Bart



More information about the fpc-devel mailing list