We are using for teaching purposes the GPC compiler under Linux (RedHat 6.1) which was installed from the following RPM packages:
gpc-19990118-1.i386.rpm gpc-extras-19990118-1.i386.rpm
Our Pascal programs are compiled with the "--borland-pascal" option.
I noticed a problem with the type "String" (and the derived types like "String[10]") and the relational operators which do not seem to return correct results. The following test program seems illustrate this point:
----------------------------------------------------------------------
program test;
procedure Compare(var x,y : String); begin if x=y then Writeln('"',x,'" = "',y,'"') else if x>y then Writeln('"',x,'" > "',y,'"') else if x<y then Writeln('"',x,'" < "',y,'"') else Writeln('"',x,'" ? "',y,'"') end; { Compare }
var a,b : String; Empty,Zeros : String;
begin a := 'abcd'; b := 'abce'; Empty := ''; Zeros := '0000'; Compare(Zeros,Zeros); Compare(Zeros,a); Compare(a,Zeros); Compare(Empty,Empty); Compare(Empty,a); Compare(a,Empty); Compare(a,a); Compare(a,b) end.
----------------------------------------------------------------------
The following output was produced:
"0000" = "0000" "0000" > "abcd" [*] "abcd" ? "0000" [*] "" = "" "" > "abcd" [*] "abcd" ? "" [*] "abcd" = "abcd" "abcd" > "abce" [*]
which shows that some results are wrong (marked with [*]).
Any suggestions as to what might be wrong?
-- Tomasz Kowaltowski