On Wed, Jun 15, 2011 at 8:15 PM, Nico Weber <[email protected]> wrote:
> You added > > char c = 42; > char* parr[5]; > memcpy(&parr[3], &c, sizeof(&c)); > > Doesn't this copy the (typically) 4-byte pointer parr[3] into the > 1-byte memory occupied by c? Shouldn't this be > > char* c; > char* parr[5]; > memcpy(&parr[3], &c, sizeof(c)); > > (In which case the old version wouldn't warn either.) > > /me feels blind > Yea.... this test case didn't end up being what I wanted. Sorry. I think I was editting it too quickly. I've provided a better test case in r133143. I'm still not sure what the right policy is, I'm looking at how hard it would be to warn on 'memset(x, 0, sizeof(x))' where 'x' is an identical expression with pointer type as that seems much more reasonable to do even if the type is 'char*'. For any purely type-based warning, I feel like in principle we shouldn't warn on essentially any uses of 'char*' or 'void*' because those types have special meaning and uses in conjunction w/ memcpy etc.
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
