title: C++ delete storage space in a different function from where it was allocated
body: <p>Will I get undefined behavior if I delete a storage space in a different function from where the space was originally allocated?</p>
  
  <pre><code>typedef struct {
      unsigned int Data1;
      unsigned int Data2;
      unsigned int Data3;
  }TData;
  
  void CreateStorage(void)
  {
      TData *TempData = new TData;
  
      DeleteStorage((unsigned char*)TempData); 
  }
  
  void DeleteStorage(unsigned char *StorageToDelete)
  {
      delete (TData*)StorageToDelete;
  }
  </code></pre>