comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitriy Anisimkov" <ts@quadrat.omsk.su>
Subject: Comparison with 0 distorts Long_Long_Integer
Date: 1998/01/14
Date: 1998-01-14T00:00:00+00:00	[thread overview]
Message-ID: <01bd20f8$c1877460$e7207cc1@----> (raw)


I'm use GNAT-3-10 for Win32 and found the BUG :
--------------------------------
with Text_Io,Machine_Code;
procedure Rli is
   use Text_Io;    

   subtype IComp is Long_Long_Integer;
   package Comp_Io is new Integer_IO(IComp); use Comp_Io;

   C : constant Icomp := 16#1234_0000_0000#;
   Cb : Icomp;
begin
   Cb := C;
   if Cb=0 then 
-- Comparison with 0 distorts Long_Long_Integer
      null;
   end if;
   if C/=Cb then
-- it's wrong
      Put(" C ="); Put(C,0,16); New_Line;
      Put(" Cb="); Put(Cb,0,16); New_Line;
   end if;
end Rli;
-------------------------------
same function in C  :

/**************************/
#include <stdio.h>
int main(void){
  signed long long int c = 0x123400000000L;
  signed long long int cb;
  cb = c;
  if(cb==0L){
    printf("Comparison with 0 distorts signed long long int");
  }
  if (c!=cb){
    printf("%l %l",c,cb);
  }
  return 0;
}
/**************************/

from C code

  if(cb==0L){...

generates assembler code

/ GNU C version 2.7.2 (i586-pc-mingw32) compiled by GNU C version 2.7.2.
...
	movl -12(%ebp),%edx
	orl %edx,-16(%ebp) ; Corruption
	cmpl $0,-16(%ebp)
	jne L2 

I think, it must be 

	movl -12(%ebp),%edx
	orl -16(%ebp),%edx
	cmpl $0,%edx
	jne L2 


Does anybody know how to correct this ? May be it is possible to change any
EXE files ?





             reply	other threads:[~1998-01-14  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-01-14  0:00 Dmitriy Anisimkov [this message]
1998-01-14  0:00 ` Comparison with 0 distorts Long_Long_Integer Robert Dewar
1998-01-15  0:00   ` Dmitriy Anisimkov
1998-01-15  0:00     ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox