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][Middle-end]79538 missing -Wformat-overflow with %s and non-member array arguments


> On Dec 14, 2017, at 1:36 PM, Jeff Law <law@redhat.com> wrote:
> 
> On 12/14/2017 12:22 PM, Qing Zhao wrote:
>> 
>>> On Dec 14, 2017, at 2:05 AM, Richard Biener <rguenther@suse.de
>>> <mailto:rguenther@suse.de>> wrote:
>>> 
>>> On Wed, 13 Dec 2017, Qing Zhao wrote:
>>> 
>>>> Hi,
>>>> 
>>>> I updated gimple-fold.c as you suggested, bootstrapped and re-tested
>>>> on both x86 and aarch64. no any issue.
>>>> 
>>>> ====
>>>> diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
>>>> index 353a46e..eb6a87a 100644
>>>> --- a/gcc/gimple-fold.c
>>>> +++ b/gcc/gimple-fold.c
>>>> @@ -1323,6 +1323,19 @@ get_range_strlen (tree arg, tree length[2],
>>>> bitmap *visited, int type,
>>>>  the array could have zero length.  */
>>>>       *minlen = ssize_int (0);
>>>>     }
>>>> +
>>>> +  if (VAR_P (arg) 
>>>> +      && TREE_CODE (TREE_TYPE (arg)) == ARRAY_TYPE)
>>>> +    {
>>>> +      val = TYPE_SIZE_UNIT (TREE_TYPE (arg));
>>>> +      if (!val || TREE_CODE (val) != INTEGER_CST || integer_zerop (val))
>>>> +return false;
>>>> +      val = wide_int_to_tree (TREE_TYPE (val), 
>>>> +      wi::sub(wi::to_wide (val), 1));
>>>> +      /* Set the minimum size to zero since the string in
>>>> + the array could have zero length.  */
>>>> +      *minlen = ssize_int (0);
>>>> +    }
>>>> }
>>>> ====
>>>> 
>>>> I plan to commit the change very soon. 
>>>> let me know if you have further comment.
>>> 
>>> Looks good to me.
>> 
>> thanks a lot for your review.
>> 
>> committed the patch as revision 255654
>> https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=255654
>> 
>> PR 79538 was filed against GCC7.0, So, I assume that this patch need to
>> be backported to GCC7 branch.
>> I will do the backporting to GCC7 later this week if there is no objection. 
> We don't try to backport all fixes to the release branches -- we tend to
> focus more on regressions that apply to those releases and codegen
> correctness issues.
> 
> I'd think a missed warning isn't that important to backport.

Okay. I see. 

then I will close PR79538 as fixed.

thanks.

Qing
> 
> Jeff


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