title: Why is static const char * template struct member not initialized
body: <p>I have some C++11 template code I am trying to port to Visual C++ Compiler 2015. The original code works just fine, however I need to rewrite it to work around issues with constexpr.</p>
  
  <p><strong><a href="http://melpon.org/wandbox/permlink/WDLbHRgchibRGwv3" rel="nofollow">The original code (simplified example)</a></strong></p>
  
  <pre><code>#include &lt;iostream&gt;
  
  struct String
  {
      static constexpr const char * value{ "STRING" };
  };
  
  template&lt;typename Base&gt;
  class Derived
  {
  public:
      static constexpr const char * value{ Base::value };
  };
  
  template&lt;typename BarType&gt;
  struct Foo
  {
      static constexpr const char * value{ BarType::value };
  };
  
  using Bar = Derived&lt;String&gt;;
  using FooBar = Foo&lt;Bar&gt;;
  
  int main()
  {
      std::cout &lt;&lt; "FooBar::value = " &lt;&lt; FooBar::value &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>This prints:</p>
  
  <pre><code>FooBar::value = STRING
  </code></pre>
  
  <p>However, when I rewrite, some static variables are not initialized. Even though it compiles just fine.</p>
  
  <p><strong><a href="http://melpon.org/wandbox/permlink/Ur1YLTICHKmv6R2T" rel="nofollow">The ported code (not working)</a></strong></p>
  
  <pre><code>#include &lt;iostream&gt;
  
  struct String
  {
      static const char * value;
  };
  const char * String::value = "STRING";
  
  template&lt;typename Base&gt;
  class Derived
  {
  public:
      static const char * value;
  };
  template&lt;typename Base&gt;
  const char * Derived&lt;Base&gt;::value = { Base::value };
  
  template&lt;typename BarType&gt;
  struct Foo
  {
      static const char * value;
  };
  template&lt;typename BarType&gt;
  const char * Foo&lt;BarType&gt;::value = { BarType::value };
  
  using Bar = Derived&lt;String&gt;;
  using FooBar = Foo&lt;Bar&gt;;
  
  int main()
  {
      std::cout &lt;&lt; "FooBar::value = " &lt;&lt; FooBar::value &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>This prints:</p>
  
  <pre><code>// nothing (Segmentation fault)
  </code></pre>
  
  <ol>
  <li><p>Why is this happening?</p></li>
  <li><p>How do I fix / work around it?</p></li>
  </ol>
  
  <p>This can be reproduced in Clang and Visual-C++, however GCC prints <code>FooBar::value = STRING</code> also in second example.</p>
  
  <p><strong>Update: <a href="http://melpon.org/wandbox/permlink/Ur1YLTICHKmv6R2T" rel="nofollow">Working solution</a></strong></p>
  
  <p>As suggested by @serge-ballesta. I prefere this solution since it is very similar to the original code. Easily applied and easily removed again when constexpr members are added to VS. </p>