title: C++ Linker Error With Class static constexpr
body: <p>I am compiling the following simple program with <code>g++-4.6.1 --std=c++0x</code>:</p>
  
  <pre><code>#include &lt;algorithm&gt;
  
  struct S
  {
      static constexpr int X = 10;
  };
  
  int main()
  {
      return std::min(S::X, 0);
  };
  </code></pre>
  
  <p>I get the following linker error:</p>
  
  <pre><code>/tmp/ccBj7UBt.o: In function `main':
  scratch.cpp:(.text+0x17): undefined reference to `S::X'
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>I realize that inline-defined static members do not have symbols defined, but I was under the (probably flawed) impression that using <code>constexpr</code> told the compiler to always treat the symbol as an expression; so, the compiler would know that it is not legal to pass a reference to the symbol <code>S::X</code> (for the same reason you can't take a reference to the literal <code>10</code>).</p>
  
  <p>However if S is declared as namespace, i.e. "namespace S" instead of "struct S", everything links fine.</p>
  
  <p>Is this a <code>g++</code> bug or do I still have to use a trick to workaround this annoyance?</p>