<div class="gmail_quote">On Wed, Jun 15, 2011 at 8:15 PM, Nico Weber <span dir="ltr"><<a href="mailto:thakis@chromium.org">thakis@chromium.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div id=":8m0">You added<br>
<br>
  char c = 42;<br>
  char* parr[5];<br>
<div class="im">  memcpy(&parr[3], &c, sizeof(&c));<br>
<br>
</div>Doesn't this copy the (typically) 4-byte pointer parr[3] into the<br>
1-byte memory occupied by c? Shouldn't this be<br>
<br>
  char* c;<br>
  char* parr[5];<br>
<div class="im">  memcpy(&parr[3], &c, sizeof(c));<br>
<br>
</div>(In which case the old version wouldn't warn either.)<br>
<br>
/me feels blind</div></blockquote></div><br><div>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*'.</div>
<div><br></div><div>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.</div>