<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">J. Gareth Moreton via fpc-devel <<a href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>> schrieb am Mi., 19. Juli 2023, 19:53:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi everyone,<br>
<br>
So I've come across a bit of awkwardness with the compiler. I'm not <br>
sure if it's a well-defined rule that I've overlooked, but in a <br>
for-loop, you can't use a 64-bit control variable when compiling for <br>
i386-win32 (and presumably other 32-bit platforms), but you can under <br>
x86_64-win64. In my case, the upper bound is a 64-bit variable (of type <br>
TConstExprInt... a record type in the compiler source), so downsizing is <br>
not ideal (although I will likely put in code that will error out if the <br>
upper bound is too large due to the risk of an malicious inputs causing <br>
said bound to equal 2^63 - 1 or 2^64 - 1).<br>
<br>
My example aside, should it be that there's a situation where pure Free <br>
Pascal code can build on a 64-bit compiler but not a 32-bit compiler? <br>
IFpermitting 64-bit control variables is too difficult for 32-bit <br>
systems, should they be forbidden entirely or at least throw a warning?<br>
<br>
Kit<br>
<br>
P.S. As the title implies, trying to use a QWord or Int64 as a for-loop <br>
control variable under i386-win32 causes an "Ordinal expression <br>
expected" error, but compiles without incident on x86_64-win64.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">It is indeed by design that not every integer type is a suitable index variable for a for-loop. In this case that a 64-bit variable can't be used on a platform with less than 64-bit width. The same is probably also true for 32-bit variables on platforms with less width (e.g. i8086, AVR, Z80). </div><div dir="auto"><br></div><div dir="auto">Cross platform code needs to cater for this accordingly. </div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div></div></div>