From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11546 invoked by alias); 29 Apr 2013 14:09:50 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 11269 invoked by uid 48); 29 Apr 2013 14:09:47 -0000 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/57111] Core dump - invalid pointer detected after std::unique_ptr Date: Mon, 29 Apr 2013 14:09:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 X-SW-Source: 2013-04/txt/msg02345.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57111 --- Comment #3 from Jonathan Wakely 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 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.