[fpc-pascal] Question: range checking for string indexing
Tom Verhoeff
T.Verhoeff at tue.nl
Wed Oct 29 21:18:34 CET 2008
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]
----------- ----------------------
s: ShortString 0 <= i <= 255
s: AnsiString 1 <= i <= Length(s)
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).
Thanks,
Tom
--
E-MAIL: T.Verhoeff @ TUE.NL | Dept. of Math. & Comp. Science
PHONE: +31 40 247 41 25 | Technische Universiteit Eindhoven
FAX: +31 40 247 54 04 | PO Box 513, NL-5600 MB Eindhoven
http://www.win.tue.nl/~wstomv/ | The Netherlands
More information about the fpc-pascal
mailing list