<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Sep 6, 2014 at 9:01 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":1gf" class="a3s" style="overflow:hidden">Here's what I can piece together:<br>
<br>
 * GCC does not intend to support `nonnull` on reference parameters. It rejects `nonnull(N)` where parameter `N` is a reference, *but* if you apply `nonnull` with no `N`, it applies to both pointer and reference parameters, and happens to have the semantics of checking for "null references".<br>
 * Clang made up its own thing in response to some non-publicly-visible radar issue, where it treats the `nonnull` attribute on references-to-pointers as applying to the pointer within the reference. This makes little sense to me, but there it is. We naturally can't optimize on the basis of `nonnull` on a reference-to-pointer like we can on a real pointer parameter/return value (we have no IR representation for that).<br>
<br>
It seems our options are to either not support `assume_aligned` on references (which would be a shame, because it's natural and useful there just as it is for pointers), or make `nonnull` and `assume_aligned` inconsistent on pointers-to-references,</div></blockquote><div><br></div><div>references-to-pointers</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":1gf" class="a3s" style="overflow:hidden"> or remove our (dubious, IMO) extension of the GNU `nonnull` semantics. I'm not happy with the third option since I don't know what the motivation for the extension is nor how many people might be relying on it, but either of the first two seem fine to me.</div></blockquote><div><br></div><div>How can you rely on it? It can't functionally break existing code, it would just introduce build errors. We could emit a warning that we are ignoring nonnull as references are always null that people could suppress.</div><div><br></div><div>I would like to remove this dubious extension unless someone at Apple can help us understand the justification. Even then, I would suggest moving it to a new, unambiguous name such as 'references_nonnull'. CC'ing Doug to comment about why this was added. If we're keeping it, considering the motivation listed was just a "rdar", we should get it documented in the user manual.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":1gf" class="a3s" style="overflow:hidden"> I don't think the connection between `nonnull` and `assume_aligned` is strong enough that the difference would be jarring for people.</div></blockquote></div><br><br></div></div>