title: std::launder and strict aliasing rule
body: <p>Consider this code:</p>
  <pre><code>void f(char * ptr)
  {
      auto int_ptr = reinterpret_cast&lt;int*&gt;(ptr); // &lt;---- line of interest 
      // use int_ptr ... 
  }
  
  void example_1()
  {
      int i = 10;    
      f(reinterpret_cast&lt;char*&gt;(&amp;i));
  }
  
  void example_2()
  {
      alignas(alignof(int)) char storage[sizeof(int)];
      new (&amp;storage) int;
      f(storage);
  }
  </code></pre>
  <p>Line of interest with call from <code>example_1</code>:</p>
  <p><strong>Q1:</strong> On the callside the <code>char</code> pointer is aliasing our integer pointer. This is valid. But is it also valid to just cast it back to an <code>int</code>? We know an <code>int</code> is within its lifetime there, but consider the function is <strong>defined in another translation unit</strong> (with no linktime optimization enabled) and the context is not known. Then all the compiler sees is: an <code>int</code> pointer wants to alias a <code>char</code> pointer, and this is violating the strict aliasing rules. So is it allowed?</p>
  <p><strong>Q2:</strong> Considering it's not allowed. We got <code>std::launder</code> in C++17. It's kind of a pointer optimization barrier mostly used to access an object which got placement <code>new</code>'ed into the storage of an object of other type or when <code>const</code> members are involved. Can we use it to give the compiler a hint and prevent undefined behavior?</p>
  <p>line of interest with call from example_2:</p>
  <p><strong>Q3:</strong> Here <code>std::launder</code> should be required, since this is the <code>std::launder</code> use case described in Q2, right?</p>
  <pre><code>auto int_ptr = std::launder(reinterpret_cast&lt;int*&gt;(ptr));
  </code></pre>
  <p>But consider again <code>f</code> is defined in another translation unit. How can the compiler know about our placement <code>new</code>, which happens on the callside? How can the compiler (only seeing function <code>f</code>) distinguish between <code>example_1</code> and <code>example_2</code>? Or is all above just hypothetical, since the strict aliasing rule would just rule out everything (remember, <code>char*</code> to <code>int*</code> not allowed) and the compiler can do what it wants?</p>
  <p>Follow-up question:</p>
  <p><strong>Q4:</strong> If all code above is wrong due to aliasing rules, consider changing the function <code>f</code> to take a void pointer:</p>
  <pre><code>void f(void* ptr)
  {
      auto int_ptr = reinterpret_cast&lt;int*&gt;(ptr); 
      // use int_ptr ... 
  }
  </code></pre>
  <p>Then we have no aliasing problem, but still there is the <code>std::launder</code> case for <code>example_2</code>. Do we have change the callside and rewrite our <code>example_2</code> function to:</p>
  <pre><code>void example_2()
  {
      alignas(alignof(int)) char storage[sizeof(int)];
      new (&amp;storage) int;
      f(std::launder(storage));
  }
  </code></pre>
  <p>or is <code>std::launder</code> in function <code>f</code> sufficient?</p>