Jump to content
msd

Delphi 12 List Objects x64

Recommended Posts

Hello Experts, 

 

I installed Delphi 12 and started to recompile all of my components from scratch (because I have a license for only full source code components).

Now, I can see some strange situation: every time I have some TList descendant VCL with some items function in 64-bit variant, I get an error.

Every item has an error because some property of the list component is not defined.

In Delphi 11.3, which was my earlier Delphi version, everything is working fine. Is there any upgrade for which I raised this problem?

 

P.S. In 32-bit varioant, everything is working fine.


Thanks in advance for any help and assistance...

 

Sample

 

if (FXLSGridSelection[FXLSGridSelection.Count - 1].RangeType = rtCol) then
begin
	FXLSGridSelection[FXLSGridSelection.Count - 1].Row2 := FXLSGridSelection[FXLSGridSelection.Count - 1].Row2 - 1;
end;

RangeType and Row1 or Row2 is not defined (in64bit) in 32bit is fine...
 

Share this post


Link to post

Hello,

 

1. FXLSGridSelection: TMapRow;

2. TMapRow = class(TList)


This is only a sample; every component that has a TList type has the same problem.

Share this post


Link to post

I was given some deep debugging procedures.

 

The problem is in TList. Count when I want to build a project in 64-bit version.

 

So count is the core of the problem. When I set a fixed integer number, everything is working fine.

 

P.S. In the 32-bit version, everything is working correctly with the count method.

 

P.P.S. 

this is not working on delphi 64 -> LastCol := Cols[Cols.Count - 1].ColNumber + 1;

this is working fine on delphi 64 -> LastCol := Cols[Integer(Cols.Count) - 1].ColNumber + 1;

Edited by msd

Share this post


Link to post

With Delphi 12 the Index type of TList as well as Count has changed from Integer to NativeInt. While this has no effect in 32 bit, with 64 bit it definitely has.

 

Check all descendants of TList if there are any declarations of properties (f.i. Items) or methods with Index type Integer which act as overloads for the base declarations. Then change these Integer types to NativeInt.

  • Thanks 1

Share this post


Link to post
1 hour ago, msd said:

P.P.S. 

this is not working on delphi 64 -> LastCol := Cols[Cols.Count - 1].ColNumber + 1;

this is working fine on delphi 64 -> LastCol := Cols[Integer(Cols.Count) - 1].ColNumber + 1;

How does that not work, exactly?  Both Count() and Items[] take NativeInt now, you should not need the type-cast.

That being said, why not use the Last() method instead?

LastCol := Cols.Last.ColNumber + 1;

 

  • Like 1

Share this post


Link to post

Hello, Remy Lebeau,

 

I was made to typecast to Integer and NativeInt, and everything is working fine now.

Your post was a little bit late, but I used this method that you described here.

 

Thanks anyway for all the information...

Share this post


Link to post
On 11/14/2023 at 3:12 AM, Remy Lebeau said:

So the typical "List.Count - 1" construction now emits "unsigned converted to signed" warning? Well done, EMB.

From my experience: unsigned numbers are inconvenient. Once you want to use a subtraction op, you get lots of warnings. And the apogee of lurking bug:

 

i: Cardinal;

for i := 0 to List.Count - 1 do

 

on an empty list which, with int overflow checks disabled, will either raise OutOfBounds on index 4B or loop 4B times - depending on a body.

Share this post


Link to post
41 minutes ago, Fr0sT.Brutal said:

So the typical "List.Count - 1" construction now emits "unsigned converted to signed" warning? Well done, EMB.

What? NativeInt is basically Int64 on a 64-bit target platform.

Share this post


Link to post
32 minutes ago, Stefan Glienke said:

What? NativeInt is basically Int64 on a 64-bit target platform.

Ah, blimey. That "U" was a phantom in my eyes. Friday 🙂

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×