patch for transfer.c

François-Xavier Coudert fxcoudert@gmail.com
Sat Aug 5 09:30:00 GMT 2006


> It's not OK. It will probably break with large files on 32-bit
> systems. Instead of casting bytes_left to size_t, nbytes should be
> cast to gfc_offset.

Hum, I tried to think it through, so let's see where logic failed me...

On usual 32-bit systems, off_t and size_t are both 32 bits; off_t is
signed and size_t is unsigned. If we happen to have nbytes larger than
INT_MAX (but smaller than UINT_MAX), casting it to off_t (a signed
int) will make it negative, and the comparison will then be
meaningless.

OTOH, if bytes_left is negative, then casting it to a unsigned int is
not good, but bytes_left simply shouldn't be negative in the first
place.

FX



More information about the Fortran mailing list