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 MEM_REF when looking for poor-man's flexible arrays (PR 86914)


On 08/14/2018 01:01 PM, Martin Sebor wrote:
> Attached is a patch to avoid calling array_at_struct_end_p()
> with a MEM_REF argument.  The function returns false even if
> the reference does point into such a flexible array member,
> as in:
> 
>   struct A { char i, a[1]; };
>   void f (struct A *p)
>   {
>     return strlen (p->a + 1);
>   }
> 
> This fix will likely be made obsolete once the string length
> range optimization is relaxed but since that's a bigger change
> I think GCC might as well emit the correct code for this case
> until then.
> 
> Martin
> 
> gcc-86914.diff
> 
> 
> PR tree-optimization/86914 - wrong code with strlen() of poor-man's flexible array member plus offset
> 
> gcc/ChangeLog:
> 
> 	PR tree-optimization/86914
> 	* tree-ssa-strlen.c (maybe_set_strlen_range): Avoid MEM_REF.
> 
> gcc/testsuite/ChangeLog:
> 
> 	PR tree-optimization/86914
> 	* gcc.dg/strlenopt-57.c: New test.
OK.
jeff


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