Re: [fpc-devel] Unexpected "Range check error while evaluating constants" when compiling for Win64

2023-02-13 Thread Bart via fpc-devel
On Sun, Feb 12, 2023 at 10:43 PM Yuriy Sydorov via fpc-devel wrote: > Error "Range check error while evaluating constants (18446744071562067969 > must be between -2147483648 and 4294967295)" > is wrong here: > > property RootKey: HKey read FRootKey write FRootKey default HKEY_CURRENT_USER; > >

Re: [fpc-devel] Unexpected "Range check error while evaluating constants" when compiling for Win64

2023-02-13 Thread Bart via fpc-devel
On Mon, Feb 13, 2023 at 8:20 AM Ondrej Pokorny via fpc-devel wrote: > I wouldn't publish the HKEY property but create an own enumeration for it: > > TRegKey = (rgClassesRoot, rgCurrentUser, ) > ... > > Then make a simple transformation to HKEY: > > RegKeyToHKey: array[TRegKey] of HKEY =

Re: [fpc-devel] Unexpected "Range check error while evaluating constants" when compiling for Win64

2023-02-13 Thread Michael Van Canneyt via fpc-devel
On Mon, 13 Feb 2023, Ondrej Pokorny via fpc-devel wrote: On 12.02.2023 23:08, Bart via fpc-devel wrote: On Sun, Feb 12, 2023 at 10:47 PM Jonas Maebe via fpc-devel wrote: Afaik it's because "default" doesn't support qword values, iirc because of (at least old) Delphi compatibility. OK, I

Re: [fpc-devel] Unexpected "Range check error while evaluating constants" when compiling for Win64

2023-02-12 Thread Ondrej Pokorny via fpc-devel
On 12.02.2023 23:08, Bart via fpc-devel wrote: On Sun, Feb 12, 2023 at 10:47 PM Jonas Maebe via fpc-devel wrote: Afaik it's because "default" doesn't support qword values, iirc because of (at least old) Delphi compatibility. OK, I removed the "default". Theoretically would that lead to

Re: [fpc-devel] Unexpected "Range check error while evaluating constants" when compiling for Win64

2023-02-12 Thread Bart via fpc-devel
On Sun, Feb 12, 2023 at 10:47 PM Jonas Maebe via fpc-devel wrote: > Afaik it's because "default" doesn't support qword values, iirc because > of (at least old) Delphi compatibility. OK, I removed the "default". Theoretically would that lead to problems when storing the value in lfm and reading

Re: [fpc-devel] Unexpected "Range check error while evaluating constants" when compiling for Win64

2023-02-12 Thread Bart via fpc-devel
On Sun, Feb 12, 2023 at 10:49 PM Bart wrote: > For 32-bit builds this results in the final HKEY value being identical > to the original literal value, but for 64-bit builds, because of the > intermediate signed LONG cast which is then cast to the larger > unsigned ULONG_PTR type, the original

Re: [fpc-devel] Unexpected "Range check error while evaluating constants" when compiling for Win64

2023-02-12 Thread Bart via fpc-devel
On Sun, Feb 12, 2023 at 10:47 PM Jonas Maebe via fpc-devel wrote: > Afaik it's because "default" doesn't support qword values, iirc because > of (at least old) Delphi compatibility. Would the original code example compile in a modern 64-bit Delphi (targeting Win64)? My old D7 doesn't even know

Re: [fpc-devel] Unexpected "Range check error while evaluating constants" when compiling for Win64

2023-02-12 Thread Bart via fpc-devel
On Sun, Feb 12, 2023 at 10:43 PM Yuriy Sydorov via fpc-devel wrote: > Declarations like this have been made on purpose: > HKEY_CURRENT_USER = HKEY(longint($8001)); > > On Win64 HKEY_CURRENT_USER must be $8001, but on Win32 it must > remain $8001. > > See commit

Re: [fpc-devel] Unexpected "Range check error while evaluating constants" when compiling for Win64

2023-02-12 Thread Jonas Maebe via fpc-devel
On 12/02/2023 22:37, Yuriy Sydorov via fpc-devel wrote: property RootKey: HKey read FRootKey write FRootKey default HKEY_CURRENT_USER; Since HKEY = THandle = QWord on Win64, the reported range for it is incorrect. Afaik it's because "default" doesn't support qword values, iirc because of

Re: [fpc-devel] Unexpected "Range check error while evaluating constants" when compiling for Win64

2023-02-12 Thread Yuriy Sydorov via fpc-devel
On 12.02.2023 23:04, J. Gareth Moreton via fpc-devel wrote: Yeah, of course, since LongInt($8001), before typecasting to HKEY, is specifically a signed constant.  So obvious!! Declarations like this have been made on purpose: HKEY_CURRENT_USER = HKEY(longint($8001)); On Win64

Re: [fpc-devel] Unexpected "Range check error while evaluating constants" when compiling for Win64

2023-02-12 Thread J. Gareth Moreton via fpc-devel
Yeah, of course, since LongInt($8001), before typecasting to HKEY, is specifically a signed constant.  So obvious!! Kit On 12/02/2023 20:43, Bart via fpc-devel wrote: On Sun, Feb 12, 2023 at 6:26 PM J. Gareth Moreton via fpc-devel wrote: If HKey is unsigned, then yes, the definition

Re: [fpc-devel] Unexpected "Range check error while evaluating constants" when compiling for Win64

2023-02-12 Thread Bart via fpc-devel
On Sun, Feb 12, 2023 at 6:26 PM J. Gareth Moreton via fpc-devel wrote: > > If HKey is unsigned, then yes, the definition should be > HKEY(DWORD($8001)). I do wonder why Win64 produces that particular > error though because the final destination is an unsigned 64-bit integer. Because

Re: [fpc-devel] Unexpected "Range check error while evaluating constants" when compiling for Win64

2023-02-12 Thread J. Gareth Moreton via fpc-devel
If HKey is unsigned, then yes, the definition should be HKEY(DWORD($8001)).  I do wonder why Win64 produces that particular error though because the final destination is an unsigned 64-bit integer. Kit On 12/02/2023 17:17, Bart via fpc-devel wrote: Hi, This code compiles happily for