Jump to content
Sign in to follow this  
Nikos

32/64bit Delphi compiler inconsistency or bug?

Recommended Posts

Hi,

TLine = class(TObjectList)
  ...
  procedure Add(const X: Real); overload;
  procedure Add(const n: Integer); overload;
  ...
end;


In Delphi 12 (Update 1), after the change of TList.Count to NativeInt from Integer, calling the Add procedure like this NewLine.Add(NewLine.Count - 1) calls the Real overloaded procedure in 64bit Delphi, and the Integer one in 32bit Delphi.
Am I doing something ambiguous, is it a Delphi compiler inconsistency or a bug?

Thanks!
 

Share this post


Link to post

NativeInt is 64-bit on Win64 so Integer overload is not appropriate (too small) there. If you want to force it to Integer overload you will have to typecast Integer(NewLine.Count - 1)

Share this post


Link to post

... or change the type in the method: Add(const n: NativeInt);

Share this post


Link to post

You're right, I should have paid more attention when migrating to Delphi 12 🙂

 

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
Sign in to follow this  

×