Prof Abimbola Olowofoyeku wrote:
On 18 Mar 2002 at 18:46, da Silva, Joe wrote:
Interesting. However, I wonder if this truncation is valid. Looking at ISO-10206, it states in section <6.4.6 Assignment-compatibility> :
"At any place where the rule of assignment-compatibility is used ... c) it shall be an error if T1 and T2 are compatible, T1 is a string-type or the char-type, and the length of the value of T2 is greater than the capacity of T1;"
My interpretation of this, is that in this situation, the statement AString:=AString+'ML' should have resulted in an error, since the compiler only allocated a capacity of 1 to AString, yet such a concatenation can never fit within this capacity.
: 3.2 Error : : A violation by a program of the requirements of this International Standard : that a processor is permitted to leave undetected.
;-)
Maybe we'll add such a check sometime ...
Perhaps in EP mode, it should generate an error. In other modes, it should [a] at least generate a warning,
Warnings only exist at compile-time. That's more difficult (the compiler would have to analyze the minimum length of the concatenation) that at runtime. Ideally, it should do both ...
or, [b] (and perhaps more controversially), treat string literals of < 255 chars as strings of 255 capacity.
No, why? For BP compatibility, it should be enough to treat `String' as `String[255]' (which GPC currently does only in contexts where an undiscriminated `String' normally makes no sense, but I think we already discussed a switch) ...
Frank