This is the mail archive of the 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

tm <> writes:

>> 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.

I haven't seen the rest of the thread yet, but yeah.  The problem case
for this code is the other way round: 64-bit build machine, 32-bit
host.  Then if the value is -(2**31), this code will not detect it as
a problem (because HOST_WIDE_INT on the *build* machine is 64 bits, so
it only considers -(2**63) to be a problem) but the emitted constant
will still hit the problem case when it's compiled for the *host*,
with 32-bit HOST_WIDE_INT.

Note also that you're printing the _build machine_'s HOST_WIDE_INT
suffix on the constant, which may be wrong for the host.


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