gpi-hash.c segfaults_(re)

Mon, 4 Aug 1997 18:14:58 +0200 (MET DST)


According to Bill Currie:
> On 31 Jul 97 at 15:08, Jukka Virtanen wrote:
> >  I suggest that this problem is fixed by casting
> >  the result of the pointer subtraction to
> >  (unsigned ptrdiff_t) which is always large enough,
> >  something like:
> 
> One slight problem: I couldn't find a `ptrdiff_t' in djgpp.  However, 
> it could always be created.

Not a slight, but a big problem: (i) See `../cccp.c', line 51; (ii)
`ptrdiff_t', even if it exists, is a signed type, and GCC doesn't accept
`unsigned ptrdiff_t'.  :-(

To work around, what about the following?  It only must produce a
more-or-less unique number ...

    /* We must avoid negative values.  Naturally, we would cast this to
     * `unsigned ptrdiff_t', but since we cannot be sure that the platform
     * we compile GPC on will support this, we use `abs' instead.
     */
    #define HASH_FUNC(NODE) ((abs ((NODE) - (tree) 0) >> 2) % MAX_HASH_TABLE)

Greetings,

    Peter

 Dipl.-Phys. Peter Gerwinski, Essen, Germany, free physicist and programmer
peter.gerwinski@uni-essen.de - http://home.pages.de/~peter.gerwinski/ [970201]
 maintainer GNU Pascal [970714] - http://home.pages.de/~gnu-pascal/ [970125]


Peter Gerwinski (peter@agnes.dida.physik.uni-essen.de)

HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada - Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es