Jan-Benedict Glaw <jbg...@lug-owl.de> wrote on 2010/04/30 16:10:42: > > On Fri, 2010-04-30 16:08:15 +0200, Joakim Tjernlund > <joakim.tjernl...@transmode.se> wrote: > > Is memcpy supposed to work when the src and dest are the same: > > memcpy(p, p, 100); > > It may work, but you cannot rely on it. Use memmove() alternatively.
My view too, but gcc 3.4.6 on gcc does this: struct my_struct { long a100[100]; }; static inline func(struct my_struct *h1, struct my_struct *h2) { *h1 = *h2; } mytest(struct my_struct *my_h1) { func(my_h1, my_h1); } ------------- .file "tst.c" .section ".text" .align 2 .globl mytest .type mytest, @function mytest: mflr 0 stwu 1,-16(1) mr 4,3 li 5,400 stw 0,20(1) bl memcpy lwz 0,20(1) addi 1,1,16 mtlr 0 blr .size mytest, .-mytest .section .note.GNU-stack,"",@progbits .ident "GCC: (GNU) 3.4.6 (Gentoo 3.4.6-r2, ssp-3.4.6-1.0, pie-8.7.9)"