title: Warning: ISO C++ forbids converting a string constant to ‘char*’ for a static `constexpr char*` data member
body: <p>Why does this code return a warning </p>
  
  <blockquote>
    <p>warning: ISO C++ forbids converting a string constant to ‘char*’
    [-Wwrite-strings]</p>
  </blockquote>
  
  <p>if </p>
  
  <blockquote>
    <p>A constexpr specifier used in an object declaration or non-static
    member function (until C++14) implies const. A constexpr specifier used in a function or static member variable (since C++17) declaration implies inline.</p>
  </blockquote>
  
  <p>(<a href="https://en.cppreference.com/w/cpp/language/constexpr" rel="noreferrer">cppreference.com</a>)</p>
  
  <pre><code>#include &lt;cassert&gt;    
  #include &lt;string&gt;    
  #include &lt;iostream&gt;    
  
  struct A     
  {    
      // warning: ISO C++ forbids converting a string constant to ‘char*’    
      static constexpr char* name_ = "A";                           
      static constexpr char* name() { return name_; };             
  };                                             
  
  int main()    
  {};    
  </code></pre>
  
  <p>If I add a <code>const</code> after <code>constexpr</code>, the warning is gone: </p>
  
  <pre><code>#include &lt;cassert&gt;    
  #include &lt;string&gt;    
  #include &lt;iostream&gt;   
  
  
  
  struct A     
  {    
      static constexpr const char* name_ = "A";    
      static constexpr const char* name() { return name_; };    
  };                                             
  
  int main()    
  {};  
  </code></pre>
  
  <p>With <code>g++ --version = g++ (GCC) 8.2.1 20181127</code>, </p>
  
  <p>compilation <code>g++ -O3 -std=c++2a -Wall main.cpp -o main</code>. </p>
  
  <p>Does the <code>constexpr</code> not imply <code>const</code> on <code>static</code> data members?</p>