On Tue, Mar 19, 2013 at 11:45:56AM +0100, Thomas Rast wrote:
Now consider
// somewhere on the stack
struct foo {
char c;
int i;
} a, b;
a.c = a.i = 0;
memcpy(&b, &a, sizeof(struct foo));
The compiler could legitimately leave the padding between c and i
uninitialized, and with your proposed "early" reporting the memcpy would
complain.
Ah, good point. And valgrind does not have any way of knowing what is
padding and what is not, since it sees only the compiled contents.
Probably llvm's memory checker support could do a better job there.
-Peff