On 09/07/18 15:36, Bernd Edlinger wrote:
> On 09/07/18 08:51, Bernd Edlinger wrote:
>> On 09/07/18 00:26, Jeff Law wrote:
>>> On 09/06/2018 04:16 PM, Jeff Law wrote:
>>>> On 09/06/2018 04:01 PM, Jeff Law wrote:
>>>>> On 09/06/2018 11:12 AM, Bernd Edlinger wrote:
>>>>>
>>>>>>>
>>>>>>
>>>>>> Ah, thanks a lot.
>>>>>>
>>>>>> Okay, this is the status of the STRING-CST semantic-v2 patches:
>>>>>>
>>>>>> [PATCH] Check the STRING_CSTs in varasm.c
>>>>>> https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01569.html
>>>>>> => Unfortunately I forgot to change the Title to [PATCHv2] or so.
>>>>>> Should I send a ping for this one?
>>>>>>
>>>>>> [PATCHv2] Handle overlength strings in the C FE
>>>>>> https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01566.html
>>>>>> => Should I send a ping for this one?
>>>>> No need to ping.  I've got it here.  What's odd is that it's regressing
>>>>> 87053 .
>>>> Which is probably a sign that we've got an incorrect test for NUL
>>>> termination somewhere.
>>
>> It may be a sign that we should first fix the low level functions
>> before the high level stuff.
>>
>>> I think I've found the issue.  I've got more testing to do, but looks
>>> like a thinko on my part.
>>>
>>
>> Ah, I forgot, the regression on pr87053 and fortran.dg/pr45636.f90
>> is fixed by this patch:
>>
>> [PATCH] Adjust c_getstr/c_strlen to new STRING_CST semantic
>> https://gcc.gnu.org/ml/gcc-patches/2018-08/msg02013.html
>>
>> This is a new regression since the patch was initially posted.
>>
> 
> Well, actually both patches seem to have a circular dependency.
> 
> If you want we can break this dependency by adding this to the  c_getstr 
> patch:
> 
> --- gcc/fold-const.c    2018-09-07 14:22:50.047964775 +0200
> +++ gcc/fold-const.c    2018-09-07 15:06:46.656989904 +0200
> @@ -14611,6 +14611,10 @@ c_getstr (tree src, unsigned HOST_WIDE_I
>     unsigned HOST_WIDE_INT string_length = TREE_STRING_LENGTH (src);
>     unsigned HOST_WIDE_INT string_size = tree_to_uhwi (mem_size);
> 
> +  /* Ideally this would turn into a gcc_checking_assert over time.  */
> +  if (string_length > string_size)
> +    return NULL;
> +
>     const char *string = TREE_STRING_POINTER (src);
> 
>     if (string_length == 0
> 
> 
> This should allow it to work with current semantics as well.
> 

Oops, this does not work for strlenopt-49.c...

Please make it:

--- gcc/fold-const.c    2018-09-07 19:39:19.555588785 +0200
+++ gcc/fold-const.c    2018-09-07 19:30:03.372583484 +0200
@@ -14611,6 +14611,10 @@ c_getstr (tree src, unsigned HOST_WIDE_I
    unsigned HOST_WIDE_INT string_length = TREE_STRING_LENGTH (src);
    unsigned HOST_WIDE_INT string_size = tree_to_uhwi (mem_size);
  
+  /* Ideally this would turn into a gcc_checking_assert over time.  */
+  if (string_length > string_size)
+    string_length = string_size;
+
    const char *string = TREE_STRING_POINTER (src);
  
    if (string_length == 0



Bernd.

Reply via email to