Hello,

I have noticed a build failure with GCC-4.5.0, when configuring with:
--build=x86_64-unknown-linux-gnu
--host=arm-none-linux-gnueabi
--target=arm-none-linux-gnueabi
The build fails when compiling gcc/genconstants.c for the build machine:
In file included from ../../gcc/rtl.h:28,
                 from ../../gcc/genconstants.c:32:
../../gcc/real.h:84: error: size of array `test_real_width' is negative

I have looked a bit at real.h, and tried to compile with -m32, which works.

Now, I think it should also work without -m32.

From my brief investigation, I think that the problem is due to the fact that struct real_value uses the 'long' type for the 'sig' field, while the computation of REAL_WIDTH relies on HOST_BITS_PER_WIDE_INT.
Promoting 'sig' to type unsigned HOST_WIDE_INT makes the compilation pass.

Here is a naive patch proposal:
--- gcc-4.5.0/gcc/real.h        2010-01-05 18:14:30.000000000 +0100
+++ gcc-4.5.0.patched/gcc/real.h        2010-08-06 14:02:03.000000000 +0200
@@ -40,11 +40,11 @@ enum real_value_class {
   rvc_nan
 };

-#define SIGNIFICAND_BITS       (128 + HOST_BITS_PER_LONG)
+#define SIGNIFICAND_BITS       (128 + HOST_BITS_PER_WIDE_INT)
 #define EXP_BITS               (32 - 6)
 #define MAX_EXP                        ((1 << (EXP_BITS - 1)) - 1)
-#define SIGSZ                  (SIGNIFICAND_BITS / HOST_BITS_PER_LONG)
-#define SIG_MSB ((unsigned long)1 << (HOST_BITS_PER_LONG - 1))
+#define SIGSZ                  (SIGNIFICAND_BITS / HOST_BITS_PER_WIDE_INT)
+#define SIG_MSB ((unsigned HOST_WIDE_INT)1 << (HOST_BITS_PER_WIDE_INT - 1))
 struct GTY(()) real_value {
   /* Use the same underlying type for all bit-fields, so as to make
@@ -56,7 +56,7 @@ struct GTY(()) real_value {
   unsigned int signalling : 1;
   unsigned int canonical : 1;
   unsigned int uexp : EXP_BITS;
-  unsigned long sig[SIGSZ];
+  unsigned HOST_WIDE_INT sig[SIGSZ];
 };


Is it OK?

Thanks,

Christophe.

Reply via email to