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: C++ PATCH for c++/39480


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.


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