summaryrefslogtreecommitdiff
path: root/fpcsrc/tests/webtbs/tw8191.pp
blob: 55b083ceb42cb0b28583b1cc4a4897530e57573e (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
29
30
31
32
33
34
35
36
37
program PCharRangeChecking;

{$APPTYPE CONSOLE}

{$ifdef fpc}
  {$mode delphi}
{$endif}

{$R+}

function Test: Boolean;
var
  s: shortstring;
  p: PChar;
begin
  s := '1234567890';
  p := PChar(@s[1]);
  Inc(p,4);

  Result :=
   (p[-4] = '1') and
   (p[-3] = '2') and
   (p[-2] = '3') and
   (p[-1] = '4') and
   (p[ 0] = '5') and
   (p[ 1] = '6') and
   (p[ 2] = '7') and
   (p[ 3] = '8') and
   (p[ 4] = '9') and
   (p[ 5] = '0');
end;

begin
  if not Test then
    halt(1);
  WriteLn('ok');
end.