title: Can I do arithmetic on void * pointers in C?
body: <p>is this valid</p>
  
  <pre><code>void *p = &amp;X; /* some thing */
  p += 12;
  </code></pre>
  
  <p>and if so what does p now point to?
  I have (third party)  code that does this (and compiles cleanly) and my guess is that the void * was treated as a char *. My trusty K&amp;R is silent(ish) on the topic</p>
  
  <p>EDIT: My little test app runs fine on gcc 4.1.1 and treats void * as char *. But g++ barfs</p>
  
  <p>I know how to do it properly. I need to know if I have to clean this code base to find all the places its done.</p>
  
  <p>BTW gcc -pedantic throws up a warning</p>
  
  <p>Summary:</p>
  
  <p>The C spec is ambiguous. It says that in terms of representation and use as function parameters void* =char*. But it is silent regarding pointer arithmetic.</p>
  
  <ul>
  <li>gcc (4) permits it and treats it as
  char *</li>
  <li>g++ refuses it </li>
  <li>gcc -pedantic warns about it</li>
  <li>vs2010 both c and c++
  refuses it</li>
  </ul>