<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Jan 4, 2017 at 11:12 AM, Aaron Ballman via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-HOEnZb"><div class="gmail-h5">So I would be opposed to ignoring those attributes in<br></div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Sema (I think we should still warn when users do nonportable things),<br>
but in favor of not changing the optimizer to capitalize on this<br>
"opportunity."<br></blockquote><div><br></div><div>I'd be opposed to ignoring the attributes only in some places and not in others. It should be ignored totally, as if it wasn't present on those functions. Doing anything else sends the wrong message -- that libc authors should continue to use nonnull on these functions because they might be helpful, and won't do anything bad.</div><div><br></div><div>But that should not be the message. The message to libc authors should be straightforward: please remove nonnull from these functions, because it's wrong.</div><div><br></div><div>E.g.</div><div>"Yes, the standard currently says you can't call e.g. memcpy(NULL, NULL, 0), but -- real user programs DO, and always have depended on being able to do so. And your library implementation is even careful to support that in its definitions of the functions. So, you should not tell the compiler that NULL is forbidden, because it would use that information to *mis*optimize people's code that is using the effectively-universal extension to the standard of allowing NULL with a zero length. In order to avoid breaking code before fixed headers are deployed everywhere, Clang has added a hack to ignore the nonnull attribute on these functions, but we'd like to be able to remove that hack in the future."<br></div><div><br></div><div><br></div></div></div></div>