summaryrefslogtreecommitdiff
path: root/fpcsrc/tests/webtbs/tw6769.pp
blob: fd1802826e1463f1ed629911d4dba4237f3f1c3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{$q+}
{$r+}

Var A, B, C : Byte;
    D : SmallInt;
Begin
A := 6;
B := 8;
C := 20;
D := -C+A+B;
if (d<>-6) then
  halt(1);
Writeln(D);
{$ifndef cpu64}
{ On 32 bit systems, A+B becomes cardinal and the -C turns the expression
  into int64 -> calculated ok.
  On 64 bit systems, A+B becomes qword and the -C keeps it qword ->
  overflow error. This can only be properly supported in 64 bit with the
  introduction of a 128 bit signed type, except if we'd use a different
  rule set in 64 bit (such as byte+byte -> cardinal and cardinal+cardinal
  -> qword, or so)
}
D := A+B-C;
if (d<>-6) then
  halt(1);
Writeln(D)
{$endif cpu64}
End.