This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Avoid printing host INT_MIN as raw digits


On Thu, 18 Dec 2003, Richard Henderson wrote:

> On Thu, Dec 18, 2003 at 11:46:24AM -0800, tm wrote:
> > !               /* These test are to suppress compiler warnings.  */
> > ! 	      if (p->tests->u.intval == -2147483647-1)
> > ! 		{
> > ! 		  printf ("-2147483647-1");
> > ! 		}
> > ! 	      else
> > ! 		{
> > ! #if HOST_BITS_PER_WIDE_INT == 64
> > ! 		  if (p->tests->u.intval == -9223372036854775807-1)
> > ! 		    {
> > ! 		      printf ("-9223372036854775807-1");
> > ! 		    }
> > ! 		  else
> > ! #endif
> > ! 		    {
> > ! 		      printf (HOST_WIDE_INT_PRINT_DEC_C, p->tests->u.intval);
> > ! 		    }
> > ! 		}
> 
> Not the prettiest.  I committed this version instead.
...
> + static void
> + print_host_wide_int (HOST_WIDE_INT val)
> + {
> +   HOST_WIDE_INT min = (unsigned HOST_WIDE_INT)1 << (HOST_BITS_PER_WIDE_INT-1);
> +   if (val == min)
> +     printf ("(" HOST_WIDE_INT_PRINT_DEC_C "-1)", val + 1);
> +   else
> +     printf (HOST_WIDE_INT_PRINT_DEC_C, val);
> + }
...

I originally wrote something similar to that, but Zack insisted it be
implemented differently so it will work properly when configured for a
Canadian cross on a 32-bit build machine to a 64-bit host machine.

Zack?

Toshi



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]