Is this undefined behaviour and why?
<p>Please, explain why this code is correct or why not:
In my opinion, line ++*p1 = *p2++ has undefined behaviour, because p1 is dereferenced first and then incrementing.</p>

<pre><code>int main()
{
   char a[] = "Hello";
   char b[] = "World";

   char* p1 = a;
   char* p2 = b;

   //*++p1 = *p2++; // is this OK?
   ++*p1 = *p2++; // is this OK? Or this is UB?

   std::cout &lt;&lt; a &lt;&lt; "\n" &lt;&lt; b;

   return 0;
}
</code></pre>
