http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57111



--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-04-29 
14:09:46 UTC ---

(In reply to comment #2)

> (In reply to comment #1)

> > That's not how you use unique_ptr.

> 

> That's besides the point when you get a dump.



No, it's entirely the point, you get a coredump because your program has

undefined behaviour when it attempts to delete a stack variable.



> If the proper use of unique_ptr with array is:

> unique_ptr<int[]> up(new int[4]); //array version of unique_ptr

> then the compiler should give a warning on "improper use", do not you think ?



The compiler can't warn about everything.  Sometimes you just have to meet the

requirements of the API you're using and not to stupid things.

Reply via email to