Adriaan van Os wrote:
Frank Heckenbach wrote:
For strings, range checking is BP compatible (access up to the capacity allowed) in `--borland-pascal' and `--delphi' modes and EP compatible (access only up to the current length allowed) otherwise. So in default (EP) mode code such as
if MyString[1] = '-' ...
without a check
if (MyString <> '') and ...
may now fail with a range-checking error. This is useful, since the first test was always undefined if `MyString' was empty, but in my experience so far, this has been one of the most common causes of range-checking errors in my code.
Shouldn't this depend on the internal representation of the respective string rather than the dialect ? BP compatible range checking for strings makes sense for UCSD-Pascal strings when implemented in GPC. UCSD-Pascal strings are not only used by --borland-pascal but also by --ucsd-pascal and --mac-pascal.
I don't think so. Access beyond the length is just as valid (for special low-level tricks) or invalid (usually), regardless of the representation.
And UCSD-Pascal strings allow access to element 0.
That's another issue. In this case you're right, UCSD strings will allow the lower bound 0 instead of 1. Frank -- Frank Heckenbach, frank@g-n-u.de, http://fjf.gnu.de/, 7977168E GPC To-Do list, latest features, fixed bugs: http://www.gnu-pascal.de/todo.html GPC download signing key: ACB3 79B2 7EB2 B7A7 EFDE D101 CD02 4C9D 0FE0 E5E8