title: Is there valid "use cases" for Undefined Behaviour?
body: <p>I have found a piece of code which has UB, and was told to leave it in the code, with a comment that states it is UB. Using MSVC2012 only.</p>
  
  <p>The code itself has a raw array of <code>Foo</code> objects, then casts that array to <code>char*</code> with <code>reinterpret_cast&lt;char*&gt;</code> and then calls <code>delete casted_array</code> (like this, not delete[]) on it.</p>
  
  <p>Like this:</p>
  
  <pre><code>Foo* foos = new Foo[500];
  
  char* CastedFoos = reinterpret_cast&lt;char*&gt;(foos);
  
  delete CastedFoos;
  </code></pre>
  
  <p>Per the Standard 5.3.5/3 this is clearly Undefined Behavior.</p>
  
  <p>Apparently this code does what it does to avoid having to call destructors as an optimisation.</p>
  
  <p>I wondered, is there actually places where leaving UB in the code could be considered <em>valid</em>?</p>
  
  <p>Also, as far as I'm concerned, leaving the above in code is not smart, am I right?</p>