From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id EC7BB431FAF for ; Sat, 27 Apr 2013 03:13:45 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -2.299 X-Spam-Level: X-Spam-Status: No, score=-2.299 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_MED=-2.3, UNPARSEABLE_RELAY=0.001] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vTg4-tH3BV7L for ; Sat, 27 Apr 2013 03:13:45 -0700 (PDT) Received: from aserp1040.oracle.com (aserp1040.oracle.com [141.146.126.69]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 5803D431FAE for ; Sat, 27 Apr 2013 03:13:45 -0700 (PDT) Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r3RADZBZ008948 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 27 Apr 2013 10:13:35 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r3RADWdT009868 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Sat, 27 Apr 2013 10:13:33 GMT Received: from ubhmt101.oracle.com (ubhmt101.oracle.com [156.151.24.6]) by userz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r3RADWFA020416; Sat, 27 Apr 2013 10:13:32 GMT Received: from pub.cz.oracle.com (/10.163.101.122) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 27 Apr 2013 03:13:32 -0700 Date: Sat, 27 Apr 2013 12:11:35 +0200 From: Vladimir Marek To: Tomi Ollila Subject: Re: [PATCH] don't store temporary value returned from c_str() Message-ID: <20130427101134.GI10394@pub.cz.oracle.com> Mail-Followup-To: Tomi Ollila , notmuch@notmuchmail.org, Vladimir Marek References: <1366405933-17223-1-git-send-email-Vladimir.Marek@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: acsinet21.oracle.com [141.146.126.237] Cc: notmuch@notmuchmail.org, Vladimir Marek X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Apr 2013 10:13:46 -0000 > > From: Vladimir Marek > > > > This is causing problems when compiled by Oracle Studio. Memory pointed > > by (const char*)term was already changed once talloc_strdup was called. > > If that changes, I'd like to understand why (and stated in the commit > message). If that is clear to everyone else I will withdraw the question -- > I am not too familiar with these iterators magic... :D Well, a) standards says that A temporary bound to a reference parameter in a function call (5.2.2) persists until the completion of the full expression containing the call (you can find the message all over the net, but I can't find actual link to the standard :-/) b) Imagine the function c_str() looks like that: const char* string::c_str(void) { char buf[100]; strcpy (buf, this->internal_representation); return buf; } you can't do: char *my_tmp = string.c_str(); printf(my_tmp); you can do: printf(string.c_str()); Hopefully I made the example right ... Cheers -- Vlad