title: Non-const reference to non-const pointer to const char
body: <p>Why can't I take a reference to <code>s2</code> in <code>foo</code>? I'm compiling with gcc 5.1.0:</p>
  
  <pre><code>#include &lt;cstring&gt;
  
  void foo(const char*&amp; p)
  {
      while (*p &amp;&amp; *p &lt;= '5')
          ++p;
  }
  
  int main()
  {
      const char *s1 = "1234567890";
      char *s2 = new char[strlen(s1) + 1];
      strcpy(s2, s1);
  
      foo(s1);  // OK
      foo(s2);  // error
  
      return 0;
  }
  </code></pre>
  
  <p>I compiled with:</p>
  
  <pre><code>$ g++ test_reference.cpp
  </code></pre>
  
  <p>The compiler gave me:</p>
  
  <pre><code>test_reference.cpp: In function ‘int main()’:
  test_reference.cpp:16:11: error: invalid initialization of non-const reference of type ‘const char*&amp;’ from an rvalue of type ‘const char*’
       foo(s2);  // error
             ^
  test_reference.cpp:3:6: note:   initializing argument 1 of ‘void foo(const char*&amp;)’
   void foo(const char*&amp; p)
        ^
  </code></pre>