This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH for c++/39480
- From: Richard Guenther <richard dot guenther at gmail dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 14 Apr 2009 11:01:27 +0200
- Subject: Re: C++ PATCH for c++/39480
- References: <49E3A60C.3080607@redhat.com>
On Mon, Apr 13, 2009 at 10:52 PM, Jason Merrill <jason@redhat.com> wrote:
> It's pedantically invalid to call memcpy to copy an object to itself, and
> apparently it even breaks on some targets. ?So avoid doing this. The best
> solution is for me to fix 22488 so we can go back to using a MODIFY_EXPR for
> copying the base subobject...
>
> Tested x86_64-pc-linux-gnu, applying to trunk, 4.4 and 4.3.
+ if (!(optimize && flag_tree_ter))
+ {
+ /* When TER is off get_pointer_alignment returns 0, so a call
+ to __builtin_memcpy is expanded as a call to memcpy, which
+ is invalid with identical args. When TER is on it is
+ expanded as a block move, which should be safe. */
This reasoning is not entirely clear to me (that is, it looks fragile to
rely on TER doing anything).
Also some targets may prefer the libcall if optimizing for size, no?
Richard.