title: Is function pointer comparison in a constexpr function allowed?
body: <p>Suppose I have a constexpr array of function pointers, and I want to write a constexpr function to find the array index for a specified function.</p>
  
  <p>I might have code like this:</p>
  
  <pre><code>void test1(){}void test2(){}void test3(){}void test4(){}
  
  typedef void(*func)(void);
  constexpr func funcs[] = { &amp;test1, &amp;test2, &amp;test3 };
  
  constexpr int FindMatchingIdx (const func work, const int idx) {
      return (work == funcs[idx]) ? (idx) : (FindMatchingIdx(work, idx + 1));
  }
  
  constexpr unsigned int loc = FindMatchingIdx (&amp;test1,0);
  </code></pre>
  
  <p>Now this code compiles on Clang and MSVC, however GCC will only compile when <code>FindMatchingIdx</code> is called with the first element in the array. If <code>FindMatchingIdx</code> is called with <code>test1</code>, GCC will compile the code, however if <code>FindMatchingIdx</code> is called with <code>test2</code> or <code>test3</code> GCC will fail to compile the code, giving the error message: </p>
  
  <blockquote>
    <p>error: '(test1 != test2)' is not a constant expression.</p>
  </blockquote>
  
  <p>If <code>FindMatchingIdx</code> has to recurse, GCC will fail to treat it as a constexpr function. Is this a bug in GCC? How does function pointer comparison even work inside a constexpr function? Obviously it can't be using real pointer values as those are assigned by the linker.</p>
  
  <p>Working example: <a href="https://godbolt.org/g/xfv1PM" rel="noreferrer">https://godbolt.org/g/xfv1PM</a></p>