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
Tomasz Kowaltowski a écrit :
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
Strange. It works correctly for me
"0000" = "0000" "0000" < "abcd" "abcd" > "0000" "" = "" "" < "abcd" "abcd" > "" "abcd" = "abcd" "abcd" < "abce"
I have DJGPP / W98 DOS Box Reading specs from c:/djgpp/lib/gcc-lib/djgpp/2.952/specs gpc version 19991030, based on 2.95.2 19991024 (release)
This is a more recent version. A bug may have been corrected
Maurice Lombardi wrote:
Tomasz Kowaltowski a écrit :
I noticed a problem with the type "String" (and the derived types like "String[10]" [...]
Strange. It works correctly for me [...] This is a more recent version. A bug may have been corrected
Indeed. It is not a plain bug, but also an incompatibility between the different Pascal dialects. Anyway, it is corrected in the still-current version gpc-19991030.
Peter
27-Apr-00 10:46 you wrote:
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
Do not even TRY to use this ancient version. Use 19991030 based on gcc 2.95.x...