[Ffmpeg-devel] [PATCH] avoid useless memcpy with src==dst (valgrind complains)

Reimar Döffinger Reimar.Doeffinger
Sun Jul 23 15:37:15 CEST 2006


Hello,
On Sun, Jul 23, 2006 at 11:07:42AM +0100, M?ns Rullg?rd wrote:
> > Huh? The problem is the assignment is obviously replaced by a memcpy by the
> > compiler,
> 
> Depends on the struct.  For small structs the compiler will generate
> load/store insns directly, and it can use knowledge of alignment to  optimize
> things.

Well, gcc 4.1.1 in this cases uses an memcpy.

> > which in case both point to the same place makes valgrind
> > complain (since src and dst are overlapping).
> 
> If the compiler does that it's broken.

Maybe. Though for src == dst I doubt any memcpy function will break
stuff. And for the overlapping case when src != dst does the C standard
specify the behaviour?
Anyway, this is not really what interests me, I'd prefer to know that
even if it is a compiler bug, may I apply the patch or do you prefer if
I don't?

Greetings,
Reimar D?ffinger




More information about the ffmpeg-devel mailing list