Recent

Author Topic: Control variable of type qword in for statement on 32bit platforms  (Read 693 times)

simone

  • Hero Member
  • *****
  • Posts: 648
I accidentally discovered that on 32bit platforms fpc does not support for loops where the control variable is of type qword.

For example, the following program:

Code: Pascal  [Select][+][-]
  1. program Project1;
  2. {$mode ObjFpc}
  3. var
  4.   ind : qword;
  5.  
  6. begin
  7.   for ind:=0 to 10 do
  8.     writeln(ind);
  9. end.

produces the following error:

project1.lpr(7,7) Error: Ordinal expression expected

I guess this depends on the size of the registers on such platforms and the conseguent optimizations.

I ask if this is expected and documented, in particular, which ordinal types are supported by the for loop on 32bit platforms.

Thanks in advance.
Microsoft Windows 10 64 bit - Lazarus 3.0 FPC 3.2.2 x86_64-win64-win32/win64

Thaddy

  • Hero Member
  • *****
  • Posts: 16653
  • Kallstadt seems a good place to evict Trump to.
Re: Control variable of type qword in for statement on 32bit platforms
« Reply #1 on: January 26, 2025, 08:35:55 pm »
It is already documented.
https://www.freepascal.org/docs-html/ref/refsu4.html#:~:text=With%20the%20exception%20of%20floating%20point%20value%20types%2C,them%20one%20by%20one%2C%20in%20a%20specified%20order.

That is the second one in 48 hours and it is documented for years.
Read manuals, not wiki's or forums.
« Last Edit: January 26, 2025, 08:38:41 pm by Thaddy »
But I am sure they don't want the Trumps back...

simone

  • Hero Member
  • *****
  • Posts: 648
Re: Control variable of type qword in for statement on 32bit platforms
« Reply #2 on: January 26, 2025, 08:39:25 pm »
I haven't posted anything in the last 48 hours. Improper tone, as usual...
« Last Edit: January 26, 2025, 08:43:21 pm by simone »
Microsoft Windows 10 64 bit - Lazarus 3.0 FPC 3.2.2 x86_64-win64-win32/win64

Thaddy

  • Hero Member
  • *****
  • Posts: 16653
  • Kallstadt seems a good place to evict Trump to.
Re: Control variable of type qword in for statement on 32bit platforms
« Reply #3 on: January 26, 2025, 09:15:40 pm »
No it was not you, you misinterpreted that:
There is a second person who asked the same question and even filed a bug report.

Hardly can see how you missed that.
But I am sure they don't want the Trumps back...

simone

  • Hero Member
  • *****
  • Posts: 648
Re: Control variable of type qword in for statement on 32bit platforms
« Reply #4 on: January 26, 2025, 09:36:59 pm »
simple, I'm not here 24/7.
Microsoft Windows 10 64 bit - Lazarus 3.0 FPC 3.2.2 x86_64-win64-win32/win64

440bx

  • Hero Member
  • *****
  • Posts: 5078
Re: Control variable of type qword in for statement on 32bit platforms
« Reply #5 on: January 26, 2025, 10:09:20 pm »
@Thaddy,

In addition to being unpleasant you didn't answer the question.  The question wasn't about ordinal types in general but _which_ ordinal types are supported by the for loop.

in particular, which ordinal types are supported by the for loop on 32bit platforms.

The answer is found at:
https://www.freepascal.org/docs-html/current/ref/refsu58.html#x168-19200013.2.4
particularly the sentence, The control variable must be an ordinal type, no other types can be used as counters in a loop.

Once that has been established then it is appropriate to refer to the ordinal types page where it is remarked that int64 and qword are not ordinal types in platforms other than 64 bit.  Therefore those types cannot be used in a "for" loop on 32 bit platforms.

Therefore, the answer is: yes, it is documented in two steps.  In the "for" loop documentation where it is stated that the control variable must be an ordinal type and in the "ordinal" types page where it is stated that some types are considered ordinal types only in 64 bit platforms.

see... ? there is no need to be rude and unpleasant about it.


(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

simone

  • Hero Member
  • *****
  • Posts: 648
Re: Control variable of type qword in for statement on 32bit platforms
« Reply #6 on: January 26, 2025, 10:24:53 pm »
Thanks 440bx for your understanding.

In fact, I had reread the documentation of the for loop in the language user guide, but I made the grave mistake of not rereading the one of ordinals.

Since I have been arbitrary accused of reading only wikis and forums, I want to point out that I read wikis very little and the forum less and less, since it is becoming unpleasant. Many who I know live the same discomfort with the forum and are abandoning it.

Congratulations.
« Last Edit: January 26, 2025, 10:26:45 pm by simone »
Microsoft Windows 10 64 bit - Lazarus 3.0 FPC 3.2.2 x86_64-win64-win32/win64

 

TinyPortal © 2005-2018