[PATCH] fix ILP32 bootstrap failures due to -Wformat-length
Martin Sebor
msebor@gmail.com
Thu Sep 22 00:39:00 GMT 2016
On 09/21/2016 05:09 PM, Jakub Jelinek wrote:
> On Wed, Sep 21, 2016 at 04:39:42PM -0600, Martin Sebor wrote:
>> diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c
>> index dddb026..652d3fb 100644
>> --- a/gcc/gimple-ssa-sprintf.c
>> +++ b/gcc/gimple-ssa-sprintf.c
>> @@ -210,8 +210,8 @@ struct format_result
>> static HOST_WIDE_INT
>> target_int_min ()
>> {
>> - static const unsigned HOST_WIDE_INT int_min
>> - = 1LLU << (sizeof int_min * CHAR_BIT
>> + const unsigned HOST_WIDE_INT int_min
>> + = 1LLU << (HOST_BITS_PER_WIDE_INT
>
> 1LLU should be really HOST_WIDE_INT_1U
>
>> - TYPE_PRECISION (integer_type_node) + 1);
>
> Is the shift amount really what you mean?
> HOST_BITS_PER_WIDE_INT - TYPE_PRECISION (integer_type_node) + 1
> is usually 33 (or 17 or 9 in much rarer cases), so that is
> 0x200000000ULL. Don't you want instead
> = HOST_WIDE_INT_1U << (TYPE_PRECISION (ingeger_type_node) - 1);
> so that it will be
> 0x80000000ULL?
Great catch, thank you! That must have been a copy and paste mistake.
>
>> @@ -221,8 +221,8 @@ target_int_min ()
>> static unsigned HOST_WIDE_INT
>> target_int_max ()
>> {
>> - static const unsigned HOST_WIDE_INT int_max
>> - = HOST_WIDE_INT_M1U >> (sizeof int_max * CHAR_BIT
>> + const unsigned HOST_WIDE_INT int_max
>> + = HOST_WIDE_INT_M1U >> (HOST_BITS_PER_WIDE_INT
>> - TYPE_PRECISION (integer_type_node) + 1);
>> return int_max;
>> }
>
> This is expectedly -1ULL >> 33, i.e. 0x7fffffffULL, which looks ok.
Thanks for double checking that. There is a test case for this
in the test suite for the optimization but there wasn't one for
the INT_MIN case. I've added it in the attached patch. I'll
beef up the return range testing some more before re-enabling
the optimization.
Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc-77676.diff
Type: text/x-patch
Size: 8480 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20160922/a8bc2582/attachment.bin>
More information about the Gcc-patches
mailing list