title: Proper way to create unique_ptr that holds an allocated array
body: <p>What is the proper way to create an unique_ptr that holds an array that is allocated on the free store? Visual studio 2013 supports this by default, but when I use gcc version 4.8.1 on Ubuntu I get memory leaks and undefined behaviour.</p>
  
  <p>The problem can be reproduced with this code:   </p>
  
  <pre><code>#include &lt;memory&gt;
  #include &lt;string.h&gt;
  
  using namespace std;
  
  int main()
  {
      unique_ptr&lt;unsigned char&gt; testData(new unsigned char[16000]());
  
      memset(testData.get(),0x12,0);
  
      return 0;
  }
  </code></pre>
  
  <p>Valgrind will give this output:</p>
  
  <pre><code>==3894== 1 errors in context 1 of 1:
  ==3894== Mismatched free() / delete / delete []
  ==3894==    at 0x4C2BADC: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==3894==    by 0x400AEF: std::default_delete&lt;unsigned char&gt;::operator()(unsigned char*) const (unique_ptr.h:67)
  ==3894==    by 0x4009D0: std::unique_ptr&lt;unsigned char, std::default_delete&lt;unsigned char&gt; &gt;::~unique_ptr() (unique_ptr.h:184)
  ==3894==    by 0x4007A9: main (test.cpp:19)
  ==3894==  Address 0x5a1a040 is 0 bytes inside a block of size 16,000 alloc'd
  ==3894==    at 0x4C2AFE7: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==3894==    by 0x40075F: main (test.cpp:15)
  </code></pre>