for in shortstring lazarus / 64-FPC development ---------------------------------------------------------------------- bytebites · 2023-12-16 12:41 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program short;uses sysutils;var s:string[20];  x: Char;begin  s:=inttostr(12345);  for x in s do write(ord(x):4);  writeln;end.  This code produces with 3.2    49  50  51  52  53 but trunk version    5  49  50  51  52  53   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 ---------------------------------------------------------------------- Bart · 2023-12-16 16:24 Confirmed. I would say: report that as a bug. (Unless Delphi behaves the same, which I cannot test, but even then....) Bart ---------------------------------------------------------------------- bytebites · 2023-12-17 15:13 I added comment to the failing commit https://gitlab.com/freepascal.or g/fpc/source/-/commit/68668c649e5aed88bac022a11a4e78bb3adb3a41 ---------------------------------------------------------------------- Bart · 2023-12-17 21:23 Not sure wether that gets noticed... I dropped him a note in the original bugreport, hopefully he gets that. Bart ---------------------------------------------------------------------- wp · 2023-12-17 23:32 Delphi 11.3 CE, BTW, does it correctly: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Project1;var  s: String[10];  ch: AnsiChar;begin  s := 'abc';  for ch in s do    Write(ord(ch), ' ');  WriteLn;  ReadLn;end. Output: Code: [Select]97 98 99 ---------------------------------------------------------------------- Bart · 2023-12-18 07:24 It's because "for .. in" for strings now uses Low and High instead of 1 and Length for it's boudaries. It was introduced because "for .. in" for zero based strings (yes, we have a compiler directive for that) was off by one. Obviousely it's a regression. Bart ---------------------------------------------------------------------- AlexTP · 2023-12-18 07:39 Posted to https://gitlab.com/freepascal.org/fpc/source/-/issues/40563