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.
Joe.
> -----Original Message-----
> From:	Frank Heckenbach [SMTP:frank@g-n-u.de]
> Sent:	Monday, March 18, 2002 8:42 AM
> To:	gpc(a)gnu.de
> Subject:	Re: Problem with gpc 2.1 RC 3
> 
> Prof Abimbola Olowofoyeku wrote:
> 
> > On 17 Mar 2002 at 13:16, Martin Liddle wrote:
> > 
> > > I have just moved to RC 3.  Looking at the list of fixed bugs it is
> > > obvious that a lot of work has been done in the last few months;
> thanks
> > > to all concerned.  The stricter type checking required a lot of effort
> > > to get our code to compile but in fairness did highlight a number of
> > > problems in our code; so I think it was time well spent.  However I am
> > > now stuck because of the following problem:
> > > 
> > > Program WriteTest;
> > > 
> > > Procedure ZWriteln(AString:String);
> > > Begin
> > >  AString:=AString+'ML';
> > >  Writeln('String [',AString,'] Length is ',Length(AString));
> > > End;
> > > 
> > > Begin
> > >  ZWriteln(' ');
> > > End.
> > > 
> > > What I see is that length is reported as 1 i.e. the string
> concatenation
> > > is failing.   Is this expected behaviour or a bug?
> > 
> > It is a bug alright. If you pass a string variable rather than a 
> > literal to 'ZWriteln', the concatentation is successful. So, something 
> > seems to have gone awry somewhere.
> 
> No, it's not a bug. `AString' is a formal parameter of
> undiscriminated schema type. This means it assumes the discriminants
> (in case of String: Capacity) of the actual parameter. In the
> example, the actual parameter is a string constant of length 1. It
> also has capacity 1, since constants can't change, anyway.
> 
> So also the parameter has capacity 1 during the execution of
> `ZWriteln'. Assigning ` ML' (the result of concatenation) to a
> capacity 1 string results in truncation to ` '. This behaviour is
> not new, BTW.
> 
	------ snip ------