[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patches] Re: Bug#582698: libc6-dev: INTMAX_MAX definition yields build failure in 32-bit C90 mode though intmax_t is supported



On Sat, May 22, 2010 at 10:49:51PM +0200, Vincent Lefevre wrote:
> The INTMAX_MAX definition in /usr/include/stdint.h yields build
> failure in 32-bit C90 mode (x86_64 machines with the -m32 gcc
> switch and x86 machines).
> 
> $ cat intmax-test.c
> #include <stdint.h>
> int main (void)
> {
>   intmax_t x;
>   x = INTMAX_MAX;
>   return 0;
> }
> $ gcc -m32 -ansi -pedantic-errors intmax-test.c
> intmax-test.c:5:1: error: use of C99 long long integer constant
> 
> Support for intmax_t is not expected to work in C90 mode, but in
> such a case, the failure should probably occur on the <stdint.h>
> inclusion or "intmax_t x;" line. Otherwise I wonder whether the
> failure on INTMAX_MAX is intended and/or fixable.
> 
> The consequence of this inconsistency is the following: for a
> software that uses intmax_t optionally (such as MPFR), as intmax_t
> works fine, autoconf detects that intmax_t is supported, but then
> the build of the software fails if it uses INTMAX_MAX.

Is this patch what you want?
--- a/sysdeps/generic/stdint.h
+++ b/sysdeps/generic/stdint.h
@@ -236,15 +236,23 @@
 #  define UINTPTR_MAX		(4294967295U)
 # endif
 
-
+# if __WORDSIZE == 64
 /* Minimum for largest signed integral type.  */
-# define INTMAX_MIN		(-__INT64_C(9223372036854775807)-1)
+#  define INTMAX_MIN		(-__INT64_C(9223372036854775807)-1)
 /* Maximum for largest signed integral type.  */
-# define INTMAX_MAX		(__INT64_C(9223372036854775807))
+#  define INTMAX_MAX		(__INT64_C(9223372036854775807))
 
 /* Maximum for largest unsigned integral type.  */
-# define UINTMAX_MAX		(__UINT64_C(18446744073709551615))
+#  define UINTMAX_MAX		(__UINT64_C(18446744073709551615))
+# else
+/* Minimum for largest signed integral type.  */
+#  define INTMAX_MIN		(-__INT32_C(2147483647)-1)
+/* Maximum for largest signed integral type.  */
+#  define INTMAX_MAX		(__INT32_C(2147483647))
 
+/* Maximum for largest unsigned integral type.  */
+#  define UINTMAX_MAX		(__UINT32_C(4294967295U))
+# endif
 
 /* Limits of other integer types.  */