<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 22 September 2014 20:03, David Krauss <span dir="ltr">&lt;<a href="mailto:david_work@me.com" target="_blank">david_work@me.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
On 2014–09–23, at 12:02 AM, Jens Maurer &lt;<a href="mailto:Jens.Maurer@gmx.net">Jens.Maurer@gmx.net</a>&gt; wrote:<br>
<br>
&gt; So, something like the following would be ill-formed?<br>
</span><span class="">…<br>
&gt; That seems unimplementable, because order-of-initialization<br>
&gt; for global variables is unspecified between translation units.<br>
<br>
</span>I think what we’re fishing for is ODR-use and ill-formed/NDR.</blockquote><div><br></div><div>I think we simply want to say that if an id-expression naming a reference appears in its own initializer, the program is ill-formed unless the id-expression is an unevaluated operand or subexpression thereof.</div><div><br></div><div><br></div><div>I don&#39;t think ill-formed, NDR is a good approach here: this is easy to diagnose in the &quot;obvious&quot; cases, and no different from other similar (non-reference) cases that lead to UB in the &quot;non-obvious&quot; cases, so I think we should make the obvious case ill-formed and leave the other cases as UB.</div><div><br></div><div>Also, ill-formed, NDR implies that *all* executions of the program have undefined behavior (if the compiler accepts it, which it&#39;s permitted to), even if they don&#39;t actually execute the UB. For instance,</div><div><br></div><div>  void f() { int &amp;r = r; }</div><div>  int main() {}</div><div><br></div><div>is a well-formed program with defined behavior today, but does not have defined behavior and does not require a diagnostic if we made this ill-formed, NDR.</div><div><br></div><div><br></div><div>I don&#39;t think that odr-use is a good approach here, since odr-use means something else (and in particular, you can name a reference in an evaluated context without odr-using it, if it&#39;s initialized by a constant expression). That is, I want this to be ill-formed:</div><div><br></div><div>  const int &amp;r = true ? 0 : r;</div><div><br></div><div>... even though the mention of &#39;r&#39; here happens to not be an odr-use.</div></div></div></div>