[fpc-devel] RTTI's GetPropValue returns corrupt Boolean value
Michael Van Canneyt
michael at freepascal.org
Tue Nov 20 15:14:51 CET 2007
On Tue, 20 Nov 2007, Graeme Geldenhuys wrote:
> Hi,
>
> I've included a program that shows the problem. I'm using FPC 2.2.0
> under Linux on a Intel P4.
> I've got a function PropertyMatch() which returns true or false if a
> given property matches a specified value. All very simple.
> But for some strange reason TypInfo.GetPropValue returns a boolean
> which seems to test ok using VarIsType(), but if I cast it as a
> boolean variant using VarIsType() just to be sure, the application
> throws the error show below.
>
> Any ideas how to resolve this issue? Is it a FPC bug? This same code
> works perfectly with Delphi 7-2007.
It depends on the choices made when converting variants to native types or
vice versa (even more difficult when it occurs in an expression).
It's hard to say whether this is an actual error or an incompatibility.
Looking at the code and the error, I'd say that somewhere along the line
fpc converted a variant to int64 instead of to an integer as delphi seems
to do.
It's just one of these reasons why it is IMHO better not to use Variants:
things happen behind the scenes that are not very clear (and that are
not documented )
Michael.
More information about the fpc-devel
mailing list