1 Return-Path: <Vladimir.Marek@Oracle.COM>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 93E9F431FBF
\r
6 for <notmuch@notmuchmail.org>; Sat, 27 Apr 2013 09:05:49 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-2.299 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_MED=-2.3, UNPARSEABLE_RELAY=0.001]
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id rsB0oxVyYv-d for <notmuch@notmuchmail.org>;
\r
17 Sat, 27 Apr 2013 09:05:49 -0700 (PDT)
\r
18 Received: from aserp1040.oracle.com (aserp1040.oracle.com [141.146.126.69])
\r
19 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 449FB431FAE
\r
22 for <notmuch@notmuchmail.org>; Sat, 27 Apr 2013 09:05:49 -0700 (PDT)
\r
23 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238])
\r
24 by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with
\r
25 ESMTP id r3RG5j9S028392
\r
26 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK);
\r
27 Sat, 27 Apr 2013 16:05:46 GMT
\r
28 Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230])
\r
29 by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id
\r
31 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL);
\r
32 Sat, 27 Apr 2013 16:05:45 GMT
\r
33 Received: from ubhmt108.oracle.com (ubhmt108.oracle.com [156.151.24.13])
\r
34 by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id
\r
35 r3RG5iRx010412; Sat, 27 Apr 2013 16:05:44 GMT
\r
36 Received: from vi64-x3-2e-prg06.cz.oracle.com (/10.163.102.127)
\r
37 by default (Oracle Beehive Gateway v4.0)
\r
38 with ESMTP ; Sat, 27 Apr 2013 09:05:43 -0700
\r
39 Date: Sat, 27 Apr 2013 18:05:40 +0200
\r
40 From: Vladimir Marek <Vladimir.Marek@Oracle.COM>
\r
41 To: Jani Nikula <jani@nikula.org>
\r
42 Subject: Re: [PATCH] don't store temporary value returned from c_str()
\r
43 Message-ID: <20130427160540.GB17459@vi64-x3-2e-prg06.cz.oracle.com>
\r
44 References: <1366405933-17223-1-git-send-email-Vladimir.Marek@oracle.com>
\r
45 <878v44qhop.fsf@nikula.org>
\r
47 Content-Type: text/plain; charset=utf-8
\r
48 Content-Disposition: inline
\r
49 In-Reply-To: <878v44qhop.fsf@nikula.org>
\r
50 User-Agent: Mutt/ (2012-12-30)
\r
51 X-Source-IP: acsinet22.oracle.com [141.146.126.238]
\r
52 Cc: notmuch@notmuchmail.org, Vladimir Marek <vlmarek@volny.cz>
\r
53 X-BeenThere: notmuch@notmuchmail.org
\r
54 X-Mailman-Version: 2.1.13
\r
56 List-Id: "Use and development of the notmuch mail system."
\r
57 <notmuch.notmuchmail.org>
\r
58 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
59 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
60 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
61 List-Post: <mailto:notmuch@notmuchmail.org>
\r
62 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
63 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
64 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
65 X-List-Received-Date: Sat, 27 Apr 2013 16:05:49 -0000
\r
67 > It's okay to use the result of .c_str() as long as the string object
\r
68 > stays in scope, and none of the non-const member functions are
\r
69 > called. Here, I think the problem is that TermIterator's overloaded
\r
70 > operator*() returns a string object within the if block's scope, and it
\r
71 > goes immediately out of scope. You could check this by adding
\r
73 Right, I overlooked that TermIterator creates temporary string (if I
\r
74 understand you correctly).
\r
79 > in function scope, and replacing (*i) with s in the if block. This might
\r
80 > also be more obvious than the presented patch, but I think the patch is
\r
83 I would prefer my change as it avoids creating another std::string. At
\r