Lesson #next: The "Conversion between ordinals and pointers is not portable" is serious, it really means "You have bungled your type-casts, your pointer arithmetics is performed in 32-bits and WILL crash on 64-bit platforms"
Most often than not is a stray longint somewhere in the mix... Combined with the compiler's rule of choosing the lowest integer size to perform calculations, a disaster.
For example,
Code:
function TChepersyMemoryManagerChunk.Alloc: pointer;
var
i, k: integer;
[...]
Exit(pointer(ptruint(Self) + ptruint(k) * f_Size));
Is a flop. Why? f_Size is a longint so the casts ptruint(k) and ptruint(Self) are useless, these are brought down to dword and everything goes to hell.
The proper solution is
Code:
Exit(pointer(ptruint(Self) + ptruint(k * f_Size)));
Lo, the warning had disappeared.
I wish the fpc dev team had chosen more informative words: I was under false impression "not portable" was referring to platforms with no pointer arithmetics.
Bookmarks