Could we agree to disagree and come together on improvements andclean-up?

Jan Wielemaker J.Wielemaker at uva.nl
Sat May 31 17:11:59 CEST 2008


On Saturday 31 May 2008 16:55:17 NightStrike wrote:
> On 5/31/08, Jan Wielemaker <J.Wielemaker at uva.nl> wrote:
> > AFAIK, the most important thing realising this is replacing 'long' by
> > int/size_t/intptr_t, as appropriate. I had to go through that myself for
> > SWI-Prolog. Ok, it is a nightmare and only needed to support Win64 but
> > in the end the code gets clearer.
>
> This is true.  Most people write code assuming that the size of long
> is equal to the size of a pointer.  This is an invalid assumption that
> is not guaranteed by the language standard, and results in code that
> is not portable.  On Win64, long is still 32 bits while pointers have
> become 64 bits.
>
> It is best to use intptr_t if it is available, and size_t secondary to
> that.  Without this change, truncation of memory addresses occurs,
> which can be very damaging indeed.  This is the most common and
> widespread porting issue.

Hopefully without starting another flamewar, let us conclude there is
only one party to blame. If any other (read smaller) party would have
done this, they would have been completely ignored by developers. And
completely right. When I learned C, the biggest int was a long and long
always fitted pointers (yes, I've seen 8,16,32 and 64 bits). Breaking
this, certainly in the light that 32-bits are getting small as a general
purpose integer, is unforgivable.

	Cheers --- Jan



More information about the gmp-discuss mailing list