Here is output from my program p compiled with Delphi (5) and FPC.
I believe that FPC fails because the first byte is chr(0)  when comparing 
70501033728 with
0.
I did run into this problem when moving code from a Pascal compiler that can 
compare
records of the same type.
In Delphi I can come around this problem creating an array of char in the 
record of the same
size and then comparing those.
But it looks like this doesn´t work in FPC.

Is this an error in FPC, or dos the compiler always look at an array of char as 
a null
terminated string.

Carsten


OK:70501033728/0
OK:70501033729/0
OK:70501033727/0

Error:70501033728/0
OK:70501033729/0
OK:70501033727/0




Free Pascal Compiler version 2.2.4 [2009/09/01] for arm
Copyright (c) 1993-2008 by Florian Klaempfl
Target OS: Linux for ARM
Compiling p.pp


Program p;


type
  t_typ=packed array[0..4] of char;
  b_typ=packed array[0..4] of byte;
  t2=record
    case integer of
      0:(t:t_typ);
      1:(b:b_typ);
      2:(i:Int64);
    end;


Var

b1,b2:t2;


Begin
  b2.i:=0;
  b1.i:=70501033728;
  if b1.t=b2.t then
    writeln('Error:',b1.i,'/',b2.i)
  else
    writeln('OK:',b1.i,'/',b2.i);
  b2.i:=0;
  b1.i:=70501033729;
  if b1.t=b2.t then
    writeln('Error:',b1.i,'/',b2.i)
  else
    writeln('OK:',b1.i,'/',b2.i);
  b1.i:=70501033727;
  if b1.t=b2.t then
    writeln('Error:',b1.i,'/',b2.i)
  else
    writeln('OK:',b1.i,'/',b2.i);
End.
------------------------------------

Error:70501033728/0
OK70501033729/0
OK70501033727/0
Med venlig hilsen
Carsten Bager

BEAS A/S
Brørupvænget 10
DK-7650 Bøvlingbjerg
Tlf. : +45 9788 5222 Fax : +45 9788 5434
www.beas.dk


_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to