Michael Knapp wrote 22 lines
I have found a Bug in FPC (1.0.2 [2000/10/12])
I have submitted it as Bug 1222:
this code displays "case failed, but it should not", but it shouldn't
CONST
c1=$80000000;
c2=$80000001;
c3=$80000002;
c4=$80000003;
VAR v:dword;
BEGIN
v:=c2;
CASE v OF
c1,c2:writeln('case c1,c2');
c3,c4:writeln('case c3,c4');
ELSE writeln('case failed, but it should not');
END;
END.
the problem/solution:
# [13] v:=c2;
movl $-2147483647,_V
# [14] CASE v OF
movl _V,%eax EAX=80000001h
subl $1,%eax EAX=80000000h, SF=1, ZF=0, CF=0
jbe .L3 Jump if (ZF=1) OR (CF=1) - NO JUMP
subl $1,%eax EAX=7FFFFFFFh, SF=0, ZF=0, CF=0
jb .L12 Jump if (CF=1) - NO JUMP
subl $1,%eax EAX=7FFFFFFEh, SF=0, ZF=0, CF=0
jbe .L6 jump if (ZF=1) OR (CF=1) - NO JUMP
jmp .L12 JUMP to .L12
.L6:
.L13:
# [16] c3,c4:writeln('case c3,c4');
[...code snipped...]
.L3:
.L17:
# [15] c1,c2:writeln('case c1,c2');
[...code snipped...]
.L12:
.L21:
# [17] ELSE writeln('case failed, but it should not'); [...code snipped...]
.L11:
# [19] END.
Michael