In message 19990511213235.C1105@esmeralda.gerwinski.de Peter Gerwinski writes:
You probably stumbled about a bug in GPC.
To help us to fix GPC it would be best if you reduced the problem to a program `david1.pas' which
is as short as possible,
reproduces the bug,
and is intended to writeln 'OK' if no bug occured and something else otherwise.
The problem is at compile-time, attached is a small module which exhibits this behaviour. My system is Red Hat Linux release 5.2 (Apollo) running kernel 2.0.36 on an i586. I've built gcc-2.8.1 and gpc 19990118.
gpc -v gives the following output ----------------------------------------------------------------- Reading specs from /usr/lib/gcc-lib/i586-pc-linux-gnu/2.8.1/specs gpc version 19990118, based on gcc-2.8.1 -----------------------------------------------------------------
Compiling the following module with gpc -c dajmod.p gives the output shown below
file dajmod.p: ----------------------------------------------------------------- module dajmod1 interface;
export dajmod = (str_tail);
procedure str_tail(protected source:string;protected i:integer;var dest:string);
end.
module dajmod1 implementation;
uses gpc; var s1,s2:string(255); i:integer;
procedure str_tail; var s2:string(255); begin (*str_tail*) if (length(source)=0) or (i<1) or (i>length(source)) then dest:='' else begin moveleft(source[length(source)-i+1], s2[1], i); (*$x+*) setlength(s2,i); (*$x-*) dest:=s2; end; end; (*str_tail*)
end. -----------------------------------------------------------------
Output from compiler: dajmod.p: In function `Str_tail': dajmod.p:9: prior parameter's size depends on `Source' -----------------------------------------------------------------
There may well already be a provided routine to do this (return the last i characters of a string), and if there is, I'd be grateful for a pointer to it, but even so I think I'd still like to be able to write similar procedures/functions.
Hi!
The problem is at compile-time, attached is a small module which exhibits this behaviour. My system is Red Hat Linux release 5.2 (Apollo) running kernel 2.0.36 on an i586. I've built gcc-2.8.1 and gpc 19990118.
gpc -v gives the following output
Reading specs from /usr/lib/gcc-lib/i586-pc-linux-gnu/2.8.1/specs gpc version 19990118, based on gcc-2.8.1
Thanks for the detailed information. :-)
Below is a version of your test program that is ready for our test suite.
To work around the bug, you can drop the first `protected'.
BTW, here are some off-topic remarks:
* In this example we are mixing Extended Pascal modules with UCSD (Borland) Pascal units. EP wants `import' instead of `uses'.
* `MoveLeft' is also an UCSD extension not present in EP.
* `SetLength' is a GPC/Delphi extension.
While GPC accepts all this, it is maybe better to stick to one flavour of modularized Pascal programming which means either EP-style modules or UCSD-style unit, but not a mixture. Furthermore if I would write an EP-style module at all, I would not use non-EP extensions. But it's a matter of taste, of course.
Thanks for the well-written bug report,
Peter