title: Legal legacy code using pointers suddenly becomes UB
body: <p>Let's say we have this legacy code from C++98:</p>
  
  <pre><code>bool expensiveCheck();
  
  struct Foo;
  
  bool someFunc()
  {
      Foo *ptr = 0;
      if( expensiveCheck() )
          ptr = new Foo;
  
      // doing something irrelevant here
      ...
      if( ptr ) {
          // using foo
      }
      delete ptr;
      return ptr; // here we have UB(Undefined Behavior) in C++11
  }
  </code></pre>
  
  <p>So basically pointer here is used to keep dynamically allocated data and use it as a flag at the same time. For me it is readable code and I believe it is legal C++98 code. Now according to this questions:</p>
  
  <p><a href="https://stackoverflow.com/questions/44182049/pointers-in-c-after-delete/44182329?noredirect=1#comment75396720_44182329">Pointers in c++ after delete</a></p>
  
  <p><a href="https://stackoverflow.com/questions/23621677/what-happens-to-the-pointer-itself-after-delete">What happens to the pointer itself after delete?</a></p>
  
  <p>this code has UB in C++11. Is it true?</p>
  
  <p>If yes another question comes in mind, I heard that committee puts significant effort not to break existing code in new standard. If I am not mistaken in this case this not true. What is the reason? Is such code considered harmfull already so nobody cares it would be broken? They did not think about consequences? This optimization is so important? Something else?</p>