Unable to read 0-th character from a string with range checking for zero based strings.
Summary
If reading 0-th character from a string with range checking for zero based strings, a range check error yields.
System Information
- Operating system: MacOS 14.6.1 (Sonoma)
- Processor architecture: AARCH64
- Compiler version: 3.2.2
- Device: Computer
Steps to reproduce
- Open Lazarus, Create a console application project
project1. - Paste the code inside
project1.lpr:
Program project1;
{$ZEROBASEDSTRINGS ON}
{$R+}
Var
I: Integer;
S: String;
Begin
S := 'abc';
WriteLn(Length(S));
For I := High(S) Downto Low(S) Do
WriteLn(I, ' ---> ', S[I]);
End.
- Save and build the application.
- Open a terminal and run the application using command line.
$ cd /path/to/project1/
$ ./project1
Example Project
What is the current bug behavior?
A runtime error 201 comes up in the terminal window:
3
2 ---> c
1 ---> b
Runtime error 201 at $00000001040A33B0
$00000001040A33B0
What is the expected (correct) behavior?
No any error, and the result should be like this:
3
2 ---> c
1 ---> b
0 ---> a
Relevant logs and/or screenshots
Possible fixes
Edited by ExSystem