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] gcc_qsort: avoid overlapping memcpy (PR 86311)


On June 25, 2018 4:52:43 PM GMT+02:00, Alexander Monakov <amonakov@ispras.ru> wrote:
>On Mon, 25 Jun 2018, Alexander Monakov wrote:
>> 
>> In PR 86311 Valgrind flags a call to memcpy with overlapping buffers.
>This can
>> happen in reorder{23,45} helpers when we're reordering in-place, and
>the 3rd/5th
>> element doesn't need to be moved: in that case the middle memcpy is
>called
>> with source == destination.
>> 
>> The fix is simple: just use a temporary, just like for other
>elements.
>
>Sigh - I see GCC optimizes memmove as well as memcpy in this case, so
>changing
>the offending memcpy calls to memmoves would be a bit cleaner. OK to go
>with
>this instead?

I think that's better. Or conditionalizing the offending ones on dest! = src? 

Richard. 

>Alexander


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