https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105651

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #17 from Jason Merrill <jason at gcc dot gnu.org> ---
Created attachment 53474
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53474&action=edit
patch to work around the issue in the library

This patch tells the optimizer that the copy can't overlap, since it is having
trouble figuring that out on its own.  This fixes the false positive.

It theoretically could deduce this from the previous two conditions: the first
establishes that the end of the source is after the end of the destination; the
second establishes that the beginning of the source is before the end of the
destination.  So the source crosses the end of the destination, and so the
length of the overlap is less than the length of the source.

There's probably a way to help the optimizer out without the
__builtin_unreachable hammer, as for 98465; suggestions are welcome.

Turning off -Wrestrict just around the call to _M_copy also works, but this
patch should also improve optimization.

Reply via email to