1 Return-Path: <david@tethera.net>
\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 09AB9431FB6
\r
6 for <notmuch@notmuchmail.org>; Mon, 29 Apr 2013 14:23:22 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id B1JMfqdcmV6O for <notmuch@notmuchmail.org>;
\r
16 Mon, 29 Apr 2013 14:23:17 -0700 (PDT)
\r
17 Received: from tesseract.cs.unb.ca (tesseract.cs.unb.ca [131.202.240.238])
\r
18 (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 8D177431FAF
\r
21 for <notmuch@notmuchmail.org>; Mon, 29 Apr 2013 14:23:17 -0700 (PDT)
\r
22 Received: from fctnnbsc30w-156034082078.dhcp-dynamic.fibreop.nb.bellaliant.net
\r
23 ([156.34.82.78] helo=zancas.localnet)
\r
24 by tesseract.cs.unb.ca with esmtpsa
\r
25 (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80)
\r
26 (envelope-from <david@tethera.net>)
\r
27 id 1UWvXP-00031x-6i; Mon, 29 Apr 2013 18:23:07 -0300
\r
28 Received: from bremner by zancas.localnet with local (Exim 4.80)
\r
29 (envelope-from <david@tethera.net>)
\r
30 id 1UWvXJ-0008IH-EY; Mon, 29 Apr 2013 18:23:01 -0300
\r
31 From: David Bremner <david@tethera.net>
\r
32 To: Vladimir Marek <Vladimir.Marek@Oracle.COM>, Jani Nikula <jani@nikula.org>
\r
33 Subject: Re: [PATCH] don't store temporary value returned from c_str()
\r
34 In-Reply-To: <20130427160540.GB17459@vi64-x3-2e-prg06.cz.oracle.com>
\r
35 References: <1366405933-17223-1-git-send-email-Vladimir.Marek@oracle.com>
\r
36 <878v44qhop.fsf@nikula.org>
\r
37 <20130427160540.GB17459@vi64-x3-2e-prg06.cz.oracle.com>
\r
38 User-Agent: Notmuch/0.15.2+84~g12d5e4e (http://notmuchmail.org) Emacs/24.2.1
\r
39 (x86_64-pc-linux-gnu)
\r
40 Date: Mon, 29 Apr 2013 18:23:01 -0300
\r
41 Message-ID: <87y5c1uj4a.fsf@zancas.localnet>
\r
43 Content-Type: text/plain
\r
45 Cc: notmuch@notmuchmail.org
\r
46 X-BeenThere: notmuch@notmuchmail.org
\r
47 X-Mailman-Version: 2.1.13
\r
49 List-Id: "Use and development of the notmuch mail system."
\r
50 <notmuch.notmuchmail.org>
\r
51 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
52 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
53 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
54 List-Post: <mailto:notmuch@notmuchmail.org>
\r
55 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
56 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
57 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
58 X-List-Received-Date: Mon, 29 Apr 2013 21:23:22 -0000
\r
60 Vladimir Marek <Vladimir.Marek@Oracle.COM> writes:
\r
62 >> It's okay to use the result of .c_str() as long as the string object
\r
63 >> stays in scope, and none of the non-const member functions are
\r
64 >> called. Here, I think the problem is that TermIterator's overloaded
\r
65 >> operator*() returns a string object within the if block's scope, and it
\r
66 >> goes immediately out of scope. You could check this by adding
\r
68 > Right, I overlooked that TermIterator creates temporary string (if I
\r
69 > understand you correctly).
\r
73 > I would prefer my change as it avoids creating another std::string. At
\r
76 Would you mind updating your commit message to reflect the best guesses
\r
77 from this discussion?
\r