willett wrote:
I too avoid length-unspecified strings.
I didn't actually say I avoid them. The vast majority of my routines does not need to enlarge their string parameters (only modify the characters in place or possibly shorten it), so an unspecified capacity works fine there. And many of them actually don't modify their parameter at all in which case a `const' parameter (also of unspecified capacity) works best.
But isn't Pascal nevertheless reporting a bug? It appears to be the equivalent of:
statement: Value of S: S:= 'AAA'; 'AAA' S:= S + 'BBB'; 'AAA'
If S has a capacity of 3, that's so. EP might require a runtime check here (which GPC doesn't do yet), BP doesn't ...
I was able to duplicate this bug in gpc version 20041218, based on gcc-3.4.3. The problem is fixed by defining a type, an alternate approach to Frank's,
Actually, that's what I suggested first:
: To avoid it, you can declare the parameter of a given capacity, say : `String (40)' (via a type-declaration, of course).
That has the problem of the artifical limitation, that my second suggestion avoids.
Frank