title: Value category of const int variable captured by lambda
body: <p>I have been attempting to understand when and when not a lambda with a capture-default odr-uses a variable with automatic storage duration defined in its surrounding scope (prompted by <a href="https://stackoverflow.com/a/43688785/1639256">this answer</a>). While exploring around this I came across a little curiosity. GCC and Clang appear to disagree about the value category of the id-expression <code>n</code> in the following code:</p>
  
  <pre><code>template &lt;typename T&gt; void assert_is_lvalue(const T&amp;) {}
  template &lt;typename T&gt; void assert_is_lvalue(const T&amp;&amp;) = delete;
  
  int main() {
      const int n = 0;
      [=] { assert_is_lvalue(n); };
  }
  </code></pre>
  
  <p>Clang compiles the code successfully, while GCC does not (<code>error: use of deleted function</code>). Which one is correct? Or is this something that is unspecified or implementation-defined?</p>
  
  <p>Binding a reference to an object is supposed to odr-use it, and this is confirmed by removing the lambda's capture-default and observing that both compilers then complain that <code>n</code> can not be implicitly captured without a capture-default.</p>
  
  <p>Marking the lambda as <code>mutable</code> makes no appreciable difference to the compilers' output.</p>