msd 5 Posted November 13, 2023 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
FPiette 382 Posted November 13, 2023 1 hour ago, msd said: FXLSGridSelection Show the declaration. 1 Share this post Link to post
msd 5 Posted November 13, 2023 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
msd 5 Posted November 13, 2023 (edited) 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 November 13, 2023 by msd Share this post Link to post
Uwe Raabe 2057 Posted November 14, 2023 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. 1 Share this post Link to post
Remy Lebeau 1393 Posted November 14, 2023 What's New: Delphi RTL and Data Improvements - Delphi RTL - List, Arrays, and Collections Improvements Quote The following is a list of improvements: ... System.Generics.Collections, System.Generics.Default, and System.Classes.TList now use NativeInt instead of Integer for all indexes. 1 Share this post Link to post
Remy Lebeau 1393 Posted November 14, 2023 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; 1 Share this post Link to post
msd 5 Posted November 14, 2023 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
Fr0sT.Brutal 900 Posted November 17, 2023 On 11/14/2023 at 3:12 AM, Remy Lebeau said: System.Generics.Collections, System.Generics.Default, and System.Classes.TList now use NativeInt instead of Integer for all indexes. 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
Stefan Glienke 2002 Posted November 17, 2023 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
Fr0sT.Brutal 900 Posted November 17, 2023 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