title: Is GCC or Clang correct about the name of a function parameter being in scope in its own default argument?
body: <p>I have a little toy program:</p>
  
  <pre><code>static int value = 0;
  
  int function(int &amp;value=value) {
      return value;
  }
  
  int main() {
      function();
  }
  </code></pre>
  
  <p>Compiling with g++ 7.2:</p>
  
  <blockquote>
    <p>g++ -std=c++11 -Wall -Wextra test.cc -o test</p>
  </blockquote>
  
  <p>No problem.</p>
  
  <p>Compiling with clang++-3.9:</p>
  
  <blockquote>
    <p>clang++-3.9 -std=c++11 -Wall -Wextra test.cc -o test</p>
  </blockquote>
  
  <pre><code>test.cc:3:25: error: default argument references parameter 'value'
  int function(int &amp;value=value) {
                          ^~~~~
  test.cc:8:5: error: no matching function for call to 'function'
      function();
      ^~~~~~~~
  test.cc:3:5: note: candidate function not viable: requires single argument 'value', but no arguments were provided
  int function(int &amp;value=value) {
      ^
  2 errors generated.
  </code></pre>
  
  <p>Kaboom.  Who's right?</p>