title: Error using a constexpr as a template parameter within the same class
body: <p>If I try to compile the following C++0x code, I get an error:</p>
  
  <pre><code>template&lt;int n&gt; struct foo { };
  
  struct bar {
      static constexpr int number() { return 256; }
  
      void function(foo&lt;number()&gt; &amp;);
  };
  </code></pre>
  
  <p>With gcc 4.6.1, the error message is:</p>
  
  <pre><code>test.cc:6:27: error: ‘static constexpr int bar::number()’ used before its definition
  test.cc:6:28: note: in template argument for type ‘int’
  </code></pre>
  
  <p>With clang 2.8, the error message is:</p>
  
  <pre><code>test.cc:6:20: error: non-type template argument of type 'int' is not an integral
        constant expression
          void function(foo&lt;number()&gt; &amp;);
                            ^~~~~~~~
  1 error generated.
  </code></pre>
  
  <p>If I move the <code>constexpr</code> function to a base class, it works on gcc, and gives the same error message on clang:</p>
  
  <pre><code>template&lt;int n&gt; struct foo { };
  
  struct base {
      static constexpr int number() { return 256; }
  };
  
  struct bar : base {
      void function(foo&lt;number()&gt; &amp;);
  };
  </code></pre>
  
  <p>Is the code wrong, or is it a limitation or bug on gcc 4.6's implementation of C++0x? If the code is wrong, why is it wrong, and which clauses of the C++11 standard say it is incorrect?</p>