On Tue, 7 Sep 2004, Frank Heckenbach wrote:
Adam Naumowicz wrote:
I've just noticed that there is a bug in the string assignment if a string is passed by value to a procedure and then assigned to.
It's not a bug. `String' is a schema type which adjusts to the actual parameter. In this case it has a capacity of 1 (since the value passed is a constant, the capacity is set equal to its length). So assigning anything longer will not fit.
Thanks, I suspected that it can be a "feature", but since there was no error/warning (knowing the strict rules of GPC parameter type checking), I expected it to make a full assignment. I strongly feel that a warning is due here.
(Or to express it low-level, as some people seem to prefer: How much space should the compiler allocate on the stack for the parameter? It can't know in advance how long a value you're going to assign to it.)
I just forgot what was the actual realization of GPC string schema and imagined that Chars is a POINTER to a char array which is dynamically allocated when necessery. A bit like FPC/Delphi Ansistrings with which all the low-level conversion stuff is done transparently for all string-like type assignments...
Regards,
Adam Naumowicz
====================================================================== Department of Applied Logic fax. +48 (85) 745-7662 Institute of Computer Science tel. +48 (85) 745-7559 (office) University of Bialystok e-mail: adamn@mizar.org Sosnowa 64, 15-887 Bialystok, Poland http://math.uwb.edu.pl/~adamn/ ======================================================================