1 / 6
Sep 2004

What cause a compilation error in the code below?

program Nu;
label m;
var num,w:byte; n: int64; i,j,q1,q2: longint;
begin
read(num);
for w:=1 to num do
begin
readln(n); q1:=round(sqrt(n/2)); q2:=round(sqrt(n));
for i:=0 to q1 do
for j:=i to q2 do
if i*i+j*j=n then begin writeln('Yes'); goto m; end
else if i*i+j*j>n then j:=q2;
writeln('No');
m:
end;
end.

I was told it's compiled OK in fp for windows.

I turned on the -Sg switch in fpc, it does compile now.
Nevertheless, it had right not to compile, it's fpc extension not turned on by default, nothing more.

lol, thanks noix.

btw I have never had this fp on my pc and absolutely ignorant of its features.

noix,

now you can turn off "labels-gotos" back. I downloaded a plain text help for FPC and found there the {$GOTO+} directive. Thanks again.

No problem. No need to turn it off, though, it shouldn't break anything.

I smell a subtle hint in here.

BREAK is good in e.g. Python's FOR statement, due to its wonderful ELSE part.

But in Pascal it sometimes sucks.