View on GitHub

IRAF Community Distribution

IRAF maintained by the community

Home | Installation | Packages | X11IRAF | PyRAF | Forum ↗

iraf-v216 · Code · Issues (50) · Pull requests (81)

iraf.net pull request #107

Adjust f2c’s internal integer size for ILP64

merge olebole merged 1 commit to iraf-community/iraf


olebole commented on 2017-10-17

To change the size of INTEGER to 64 bit it is not enough to just patch f2c.h, also the length of an integer must be adjusted in the f2c sources, since it is f.e. needed to determine the largest type to use in an EQUIVALENCE statement. Otherwise, the wrong type may be used there as the general type. This happens f.e. in ieeer.x:

int	expon, i, val  
real	fval  
int	ival[1]  
%	equivalence (fval, ival)  
%	equivalence (ival, val)  

translates by the current f2c.e to

    static real equiv_1[1];  
  
    /* Local variables */  
    static integer i__;  
#define val ((integer *)equiv_1)  
#define fval (equiv_1)  
#define ival ((integer *)equiv_1)  

This is wrong: on ILP64, real is a 4-byte floating point, while integer is an 8-byte integer. Dereferencing ival will therefore cause reading memory outside of the definition of rval, which is an error and may cause segmentation faults. The reason is that f2c.e uses the variable with the largest size for storage, and since in the original f2c code real and integer are both 4 bytes, it has the freedom to use either of them (and choosed real).

This PR changes the size of INTEGER to 8 bytes on 64 bit platforms, in conformance with its length specified in f2c.h. Then, the definition is properly changed to integer on those platforms.


Commits


Last updated on 2017-11-16