From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 40638 invoked by alias); 27 Sep 2016 18:32:32 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 40625 invoked by uid 89); 27 Sep 2016 18:32:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.8 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: albireo.enyo.de Received: from albireo.enyo.de (HELO albireo.enyo.de) (5.158.152.32) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 27 Sep 2016 18:32:30 +0000 Received: from [172.17.203.2] (helo=deneb.enyo.de) by albireo.enyo.de with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) id 1boxB3-0000s5-PR; Tue, 27 Sep 2016 20:32:25 +0200 Received: from fw by deneb.enyo.de with local (Exim 4.84_2) (envelope-from ) id 1boxB3-0004Qs-Ku; Tue, 27 Sep 2016 20:32:25 +0200 From: Florian Weimer To: Nikolaus Dunn Cc: Jonathan Wakely , gcc-help Subject: Re: Optimization question References: <87zimt5pza.fsf@mid.deneb.enyo.de> <4e4b52d1-d9fd-ef2b-6e53-99f4b68a9c4b@gmail.com> Date: Tue, 27 Sep 2016 18:32:00 -0000 In-Reply-To: <4e4b52d1-d9fd-ef2b-6e53-99f4b68a9c4b@gmail.com> (Nikolaus Dunn's message of "Tue, 27 Sep 2016 13:39:01 -0400") Message-ID: <87zimtxkg6.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2016-09/txt/msg00109.txt.bz2 * Nikolaus Dunn: > std::ostringstream however does not call my new OR delete with no > optimization. With -O2, it calls only my delete. > > If I do not attempt to wrap malloc and free, I get the same > result. std::vector calls my new and delete, ostringstream calls > neither. > > The command line I used to compile it is: > g++ -g -O2 --std=3Dc++14 -Wl,-wrap,malloc -Wl,-wrap,free Test.c -o test.e= xe =E2=80=9C-Wl,-wrap,malloc -Wl,-wrap,free=E2=80=9D is only effective for new= ly-compiled code. Your example probably uses some template instantiations which are supplied by libstdc++, and these will keep calling the unwrapped malloc/free implementations. I don't know if there are mechanisms on mingw which are comparable to ELF symbol interposition.