[fpc-devel] Warning: Conversion between ordinals and pointers is not portable
lazarus at mfriebe.de
Thu Dec 6 14:27:46 CET 2012
On 06/12/2012 13:16, Jonas Maebe wrote:
> On 06 Dec 2012, at 14:03, Martin wrote:
>> Yet what I do not understand, is why I get that message as warning
>> (as opposed to a hint). If I understand it right (I have not tested,
>> maybe it gives a warning on 64 bit target too, if so ignore the
>> rest), and I compile for a 64bit target, then it downgrades to a
>> hint again?
> Yes. If you typecast an integer to a pointer and both have the same
> size, you get a hint. If they have a different size, you get a warning.
>> The only difference is, that in the above example, if compiled for a
>> 32 bit system, I already may have broken code. But then what it
>> actually means is that I should get warning about a truncating the
>> b := byte(a);
>> Gives no warning at all.
> That's because truncating integers cannot result in invalid addresses.
> The warning was added to help people moving from 32 bit to 64 bit
> systems and using longint typecasts in their programs to convert
> between addresses and integers. There are very few cases whereby
> discarding the upper 32 bit of a pointer is intended or results in
> valid code.
It was only that I was working on 3cd party code, with many pointer
casts. And some did warn, some not (add to that that the IDE did hide
the hints. And I couldn't work out why I only got some warnings, and not
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fpc-devel