Here's the fix that I now committed:
2006-06-15 Bruno Haible <[EMAIL PROTECTED]>
* size_max.m4 (gl_SIZE_MAX): Make it work also when cross-compiling.
*** size_max.m4 11 Jul 2005 11:29:40 - 1.4
--- size_max.m4 16 Jun 2006 13:12:33 -
***
*** 1,5
! # size_max
Paul Eggert wrote:
> The basic idea seems fine, but isn't that off by a factor of 2? It defines
> size_t_bits_minus_2 = sizeof (size_t) * CHAR_BIT - 2
> and then defines SIZE_MAX to (((1U << $size_t_bits_minus_2) - 1) * 2 + 1).
> Unless I'm missing something, on a 32-bit host, that will set SIZE_M
The basic idea seems fine, but isn't that off by a factor of 2? It defines
size_t_bits_minus_2 = sizeof (size_t) * CHAR_BIT - 2
and then defines SIZE_MAX to (((1U << $size_t_bits_minus_2) - 1) * 2 + 1).
Unless I'm missing something, on a 32-bit host, that will set SIZE_MAX
to 2147483647 instead of
Hi,
The size_max macro has a bug: it assumes that 'expr' can deal with numbers as
large as SIZE_MAX/10. Which is not true when cross-compiling from a 32-bit
platform to a 64-bit platform.
Here is a fix, that takes care that SIZE_MAX is valid in preprocessor
expressions (i.e. contains no casts).