vishapoberon / compiler

vishap oberon compiler
http://oberon.vishap.am
GNU General Public License v3.0
186 stars 25 forks source link

IS type test on x86_64 #46

Open norayr opened 7 years ago

norayr commented 7 years ago

Looks like Texts module does not always return R.eot on 64bit systems. Illustration is here. That happens because

IF u IS Piece

in the procedure Read may return TRUE on 64bit systems, while in the same situation it returns FALSE on 32bit systems.

64bit system:

32bit system:

this is the macro which implements the IS test:

#define __ISP(p, typ, level)  __IS(__TYPEOF(p),typ,level)

It's in SYSTEM.h and does not work correctly on 64bit systems.

norayr commented 7 years ago

this is checked both with 1.1 and 1.95 versions.

norayr commented 7 years ago

with ADRINT branch, compilation issues:

noch@debed /tmp/ocat $ /opt/voc/bin/voc -m test.Mod 
test.Mod  compiling test.  Main program.  1311 chars.
In file included from test.c:8:0:
test.c: In function ‘EnumPtrs’:
test.c:26:19: warning: passing argument 2 of ‘SYSTEM_ENUMR’ from incompatible pointer type
  __ENUMR(&test_R, Texts_Reader__typ, 72, 1, P);
                   ^
/opt/voc/2/include/SYSTEM.h:323:57: note: in definition of macro ‘__ENUMR’
 #define __ENUMR(adr, typ, size, n, P) SYSTEM_ENUMR(adr, typ, (address)(size), (address)(n), P)
                                                         ^
/opt/voc/2/include/SYSTEM.h:301:13: note: expected ‘int64 *’ but argument is of type ‘int32 *’
 extern void SYSTEM_ENUMR  (void *adr, address *typ, address size, address n, void (*P)());

however R.eot becomes TRUE on x86_64 when it has to. (:

dcwbrown commented 7 years ago

Hmm. Texts_Readertyp is declared on line 181 of Texts.c as 'address'. And SYSTEMENUMR expects an 'address', so initially I'm stumped. I don't get the compiler warning on my build in cygwin. The error suggests that texts.c was compiled with address=int32, and SYSTEM.H with address=int64. I can't easily see how that would be possible. To guarantee a clean build you can do

  1. make uninstall then check that opt/voc has been removed, and remove it manually if not.
  2. make full Then rm test.[ch] test.sym test.o etc. before trying voc again.
dcwbrown commented 7 years ago

Oops, markdown! both those 'address's should be 'address*'.