Traditional Synergy Compiler Should Error On Type-Mismatches for ^ADDR
Consider the following code:
main record workVars badPointer, i4 goodPointer, D_ADDR endrecord proc goodPointer = ^addr(workVars) nop; badPointer = ^addr(workVars) nop; endmain
Compiling this in a 32bit world this code "works"; badPointer and goodPointer are "equivalent".
If you compile this code in 64bit however you are playing with fire.
The documentation clearly states that ^ADDR is expected to return a D_ADDR not an I4, not an I8, a D_ADDR; however there is absolutely NO Compiler check to validate that this guidance was ever followed.
To further compound issues even when using the maximum warning level and compiling in 64bit you get these useless warnings:
Severity Code Description Project File Line Suppression State Warning %DBL-W-NARROWING, Narrowing conversion could cause loss of data : badPointer = ^addr(workVars) ADDRBugs C:\Users\aceo\source\repos\ADDRBugs\ADDRBugs\Program.dbl 11 Warning %DBL-W-NARROWING, Narrowing conversion could cause loss of data : goodPointer = ^addr(workVars) ADDRBugs C:\Users\aceo\source\repos\ADDRBugs\ADDRBugs\Program.dbl 8
While I would completely agree with the first warning, the second warning is flat out wrong. x86 happily reports nothing.
This really needs to be a compiler stopping ERROR (not a WARNING an ERROR).
.define D_NATINT, I4 ;SIZE of native int in C. .define D_ADDR, I8 ;CHAR * POINTERS ARE 8 BYTES LONG .define D_ADDRSIZE, 8 ;CHAR * POINTERS ARE 8 BYTES LONG .define D_NATLNG, I8 ;SIZE of native long in C. .define D_HANDLE, i4
This the definition from dbl.def on a 64-bit machine which shows that an I4 is the equivalent of an 'int' in C++/C# terms and the I8 is the equivalent of a 'long'. Using any of those compilers you would have an error if you didn't explicitly cast from the larger one to the smaller.
11/22/2019 8:31 AM 1
What version of Synergy do you have installed D_NATLNG is defined as I8? We have a tracker open (Case #098713) that shows this defined as an I4. This is the value of our dbl.def from a 10.3.3g RTM install + latest hotfixes (note the incorrect comments as well):
.define D_ADDR, I8 ;CHAR * POINTERS ARE 4 BYTES LONG .define D_ADDRSIZE, 8 ;CHAR * POINTERS ARE 4 BYTES LONG .define D_NATINT, I4 ;SIZE of native int in C. .define D_NATLNG, I4 ;SIZE of native long in C. .define D_MAXINT, I8 ;max supported int size
The file properties are:
C:\Program Files\Synergex\SynergyDE\dbl>rhash -H dbl.def d2a1209abb8874a0e7e04ed0ab92eba013979162 dbl.def C:\Program Files\Synergex\SynergyDE\dbl>dir dbl.def Volume in drive C has no label. Directory of C:\Program Files\Synergex\SynergyDE\dbl 01/18/2019 12:08 PM 10,206 dbl.def 1 File(s) 10,206 bytes 0 Dir(s) 167,361,449,984 bytes free
11/22/2019 3:28 PM 0
12/9/2019 8:50 AM 0
12/13/2019 8:17 PM 0
D_NATINT is the platform defined size of the int datatype in the operating system c header files.
D_NATLNG is the platform defined size of the long datatype in the operating system c header files.
On all 32bit software and windows they are both 4. On Non windows 64 bit systems D_NATLNG is 64.
D_ADDR is the size of a pointer, which is 32 for 32 bit programs and VMS, and 64 for non VMS 64 programs.
Hence the difference in size from Windows and Linux.
12/19/2019 5:39 PM 0