title: Why is 'volatile' parasitic in C++?
body: <p>Consider the following code:</p>
  
  <pre><code>int main()                                                                      
  {                                                                             
      int i;                                                                      
      volatile int* p = &amp;i;                                                       
      int *v = p;                                                                 
      return 0;                                                                   
  }
  </code></pre>
  
  <p>This gives an error in <code>g++</code>:</p>
  
  <pre><code>$ g++ -o volatile volatile.cpp 
  volatile.cpp: In function ‘int main()’:
  volatile.cpp:6: error: invalid conversion from ‘volatile int*’ to ‘int*’
  </code></pre>
  
  <p>My intention was that I want to make <code>p</code> volatile.  However, once I've read the value of <code>p</code>, I don't care if accessing <code>v</code> is volatile.  Why is it required that <code>v</code> be declared volatile?</p>
  
  <p>This is hypothetical code of course.  In a real situation you could imagine that <code>p</code> points to a memory location, but is modified externally and I want <code>v</code> to point to the location that <code>p</code> pointed to at the time of <code>v = p</code>, even if later <code>p</code> is externally modified.  Therefore <code>p</code> is volatile, but <code>v</code> is not.</p>
  
  <p>By the way I am interested in the behaviour both when this is considered C and C++, but in C this only generates a warning, not an error.</p>