title: Argument only used in unevaluated context within the body of a constexpr function
body: <p>The following piece of code has successfully compiled with gcc 5.3.0 but has failed to compile with clang 3.7.0. I used the online coliru compilers with the same command line options in both cases: -std=c++14 -O2 -Wall -pedantic -pthread.</p>
  
  <pre><code>#include &lt;cstdio&gt;
  
  // Definition of constexpr function 'foo'.
  constexpr std::size_t foo(const int&amp; arg_foo) { return sizeof(arg_foo); }
  
  // Definition of function 'test'.
  void test(const int&amp; arg)
  { 
    // The following line produces an error with clang.
    constexpr std::size_t res_foo = foo(arg);
  
    // Print the result returned by the 'foo' function.
    std::printf("res_foo = %lu\n", res_foo);
  }
  
  // Definition of function 'main'.
  int main(int argc, const char* argv[])
  {
    // Test function call.
    test(argc);
  
    // Return statement.
    return 0;
  }
  </code></pre>
  
  <p>clang rejects it with the following error:</p>
  
  <pre><code>error: constexpr variable 'res_foo' must be initialized by a constant expression
  constexpr size_t res_foo = foo(arg);
                             ~~~~^~~~
  </code></pre>
  
  <p>Because of this difference between the two compilers, I am wondering if this is a valid piece of code. If not, I would like to get a better understanding of why this is the case.</p>