title: Constexpr static member function usage
body: <p>Consider the following example code:</p>
  
  <pre><code>#include &lt;array&gt;
  
  struct MyClass
  {
    size_t value = 0;
  
    constexpr static size_t size() noexcept
    {
      return 3;
    }
  };
  
  template &lt;size_t N&gt;
  void DoIt()
  {
    MyClass h;
    std::array&lt;int, h.size()&gt; arr;
  }
  
  int main()
  {
    DoIt&lt;1&gt;();
  }
  </code></pre>
  
  <p>When I try to compile this with GCC 7.3.0, I get an error about h not being usable in a non-constexpr context:</p>
  
  <pre><code>cexpr.cpp: In function ‘void DoIt()’:
  cexpr.cpp:17:26: error: the value of ‘h’ is not usable in a constant expression
     std::array&lt;int, h.size()&gt; arr;
                            ^
  cexpr.cpp:16:11: note: ‘h’ was not declared ‘constexpr’
     MyClass h;
             ^
  cexpr.cpp:17:27: error: the value of ‘h’ is not usable in a constant expression
     std::array&lt;int, h.size()&gt; arr;
                             ^
  cexpr.cpp:16:11: note: ‘h’ was not declared ‘constexpr’
     MyClass h;
             ^
  </code></pre>
  
  <p>However, when I try compiling the exact same code in Clang 6.0.0, it compiles without any errors. Additionally, when I modify the code to not be inside the templated <code>DoIt()</code> function, GCC compiles this just fine:</p>
  
  <pre><code>#include &lt;array&gt;
  
  struct MyClass
  {
    size_t value = 0;
  
    constexpr static size_t size() noexcept
    {
      return 3;
    }
  };
  
  int main()
  {
    MyClass h;
    // this compiles just fine in Clang and GCC
    std::array&lt;int, h.size()&gt; arr;
  }
  </code></pre>
  
  <p>I already know how to fix the first code so it compiles on GCC using <code>decltype</code>, but I'm curious to know why doesn't the first piece of code compile with GCC? Is this just a bug in GCC, or is there something I don't understand about using constexpr static member functions?</p>