Go Back
1 Vote

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).

5 Comments | Posted by Ace Olszowka to Synergy DBL on 11/15/2019 8:04 PM
Mark Vinten
That isn't happening due to the narrowing that you've mentioned in your I4/I8 assignment post.  I think I already said there that I woudl expect there to be a bound checking error, so I woudl agree that assigning a 64-bit D_ADDR into an I4 should be 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  
Ace Olszowka

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  
Mark Vinten
That would be 64-bit linux.  I would have expected the same for 64-bit Synergy/DE on Windows too, with the 32-bit version being I4.

12/9/2019 8:50 AM   0  
Jerry Fawcett
We created tracker 38714 to address the incorrect warning mentioned above as we consider that a bug. To clarify, this tracker does not implement the idea posted, and we welcome additional customer input on this.

12/13/2019 8:17 PM   0  
Phillip Bratt
Wanted to make an additional post on this to clear up the confusion about the inconsistency of D_NATINT and D_NATLNG between Linux and Windows.

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  
Please log in to comment on this idea.