Martin G C Davies wrote:
gpc -v Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.8.1/specs gpc version 20011222, based on gcc-2.8.1
I have to use gcc-2.8.1 because later versions have a bug with goto out multiple levels (as discussed in this forum before).
My new problem is with source:-
program Hello ;
function covers( var p1 , p2 : integer ) : boolean ; begin if ( p1 = p2 ) then begin covers := false ; writeln( 'mgcd covers returns false 1' ) ; return ; end ;
covers := true ; writeln( 'mgcd covers returns true' ) ;
end ;
var i1, i2 : integer ; begin i1 := 1 ; i2 := 1 ; writeln( 'covers=' , covers( i1 , i2 ) ) ; end.
When I run it I get:-
mgcd covers returns false 1 covers=True
I could not find a reference to this problem. The problem was not introduced in 20011222 because 20010924 shows the same problem.
You use `Return' without parameters which returns an arbitrary (undefined) value. If you compile with `-Wall' (always recommended), you'll see this problem immediately.
You can use `Exit' instead of `Return' to avoid this problem. Both are non-standard, BTW (`Exit' comaptible to BP, `Return' to C-; and perhaps some other Pascal compilers). The "clean" solution, and very easy to do here, would be to use an `else' branch.
Frank