Re: [fpc-pascal] Question: range checking for string indexing

2008-10-30 Thread Vinzent Höfler
Tom Verhoeff wrote: On Wed, Oct 29, 2008 at 09:58:10PM +0100, Vinzent Höfler wrote: Tom Verhoeff wrote: I am surprised that for ShortString, the range is not also 1 <= i <= Length(s). IIRC Turbo Pascal only allowed you to access s[0] when range checking was off, and similarly for s[i] with i

Re: [fpc-pascal] Question: range checking for string indexing

2008-10-30 Thread Frank Peelo
Tom Verhoeff wrote: On Wed, Oct 29, 2008 at 09:58:10PM +0100, Vinzent Höfler wrote: Tom Verhoeff wrote: I am surprised that for ShortString, the range is not also 1 <= i <= Length(s). IIRC Turbo Pascal only allowed you to access s[0] when range checking was off, and similarly for s[i] with

Re: [fpc-pascal] Question: range checking for string indexing

2008-10-30 Thread Tom Verhoeff
On Wed, Oct 29, 2008 at 09:58:10PM +0100, Vinzent Höfler wrote: > Tom Verhoeff wrote: > >> I am surprised that for ShortString, the range is not >> also 1 <= i <= Length(s). >> >> IIRC Turbo Pascal only allowed you to access s[0] when range checking >> was off, and similarly for s[i] with i > Lengt

Re: [fpc-pascal] Question: range checking for string indexing

2008-10-29 Thread Vinzent Höfler
Tom Verhoeff wrote: I am surprised that for ShortString, the range is not also 1 <= i <= Length(s). IIRC Turbo Pascal only allowed you to access s[0] when range checking was off, and similarly for s[i] with i > Length(s). No. See transcript: -- 8< -- the program -- {$R+} var s1 : String;

[fpc-pascal] Question: range checking for string indexing

2008-10-29 Thread Tom Verhoeff
Can someone confirm what range checking FreePascal does (if enabled) when indexing a string. I imagine shortstrings and ansistrings are handled differently, but cannot find this in the documentation. It looks like the following: String Type Range Checked for s[i] ---