title: Getting new-delete-type-mismatch from ASAN
body: <p>I compiled my code using <code>-fsanitize=address</code> and am getting this error:</p>
  
  <pre><code>==53702==ERROR: AddressSanitizer: new-delete-type-mismatch on 0x60300000efe0 in thread T0:
    object passed to delete has wrong type:
    size of the allocated type:   24 bytes;
    size of the deallocated type: 1 bytes.
      #0 0x7fd544b7b0a0 in operator delete(void*, unsigned long) /home/user/objdir/../gcc-6.3.0/libsanitizer/asan/asan_new_delete.cc:108
      #1 0x4010c4 in foo() /home/user/asan.cpp:27
      #2 0x40117e in main /home/user/asan.cpp:33
      #3 0x7fd543e7082f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
      #4 0x400f48 in _start (/home/user/a.out+0x400f48)
  </code></pre>
  
  <p>Example Code:</p>
  
  <pre><code>#include &lt;memory&gt;
  
  struct T {
    T() : v(100) {}
    std::vector&lt;int&gt; v;
  };
  
  struct A {};
  
  struct B : public A {
    T t;
  };
  
  int main() {
    A *a = new B;
    delete a;
  
    std::unique_ptr&lt;A&gt; a1 = std::make_unique&lt;B&gt;();
  
    return 0;
  }
  </code></pre>