--- /dev/null
+Return-Path: <Vladimir.Marek@Oracle.COM>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 93E9F431FBF\r
+ for <notmuch@notmuchmail.org>; Sat, 27 Apr 2013 09:05:49 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.299\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.299 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_MED=-2.3, UNPARSEABLE_RELAY=0.001]\r
+ autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id rsB0oxVyYv-d for <notmuch@notmuchmail.org>;\r
+ Sat, 27 Apr 2013 09:05:49 -0700 (PDT)\r
+Received: from aserp1040.oracle.com (aserp1040.oracle.com [141.146.126.69])\r
+ (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 449FB431FAE\r
+ for <notmuch@notmuchmail.org>; Sat, 27 Apr 2013 09:05:49 -0700 (PDT)\r
+Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238])\r
+ by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with\r
+ ESMTP id r3RG5j9S028392\r
+ (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK);\r
+ Sat, 27 Apr 2013 16:05:46 GMT\r
+Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230])\r
+ by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id\r
+ r3RG5iAd008228\r
+ (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL);\r
+ Sat, 27 Apr 2013 16:05:45 GMT\r
+Received: from ubhmt108.oracle.com (ubhmt108.oracle.com [156.151.24.13])\r
+ by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id\r
+ r3RG5iRx010412; Sat, 27 Apr 2013 16:05:44 GMT\r
+Received: from vi64-x3-2e-prg06.cz.oracle.com (/10.163.102.127)\r
+ by default (Oracle Beehive Gateway v4.0)\r
+ with ESMTP ; Sat, 27 Apr 2013 09:05:43 -0700\r
+Date: Sat, 27 Apr 2013 18:05:40 +0200\r
+From: Vladimir Marek <Vladimir.Marek@Oracle.COM>\r
+To: Jani Nikula <jani@nikula.org>\r
+Subject: Re: [PATCH] don't store temporary value returned from c_str()\r
+Message-ID: <20130427160540.GB17459@vi64-x3-2e-prg06.cz.oracle.com>\r
+References: <1366405933-17223-1-git-send-email-Vladimir.Marek@oracle.com>\r
+ <878v44qhop.fsf@nikula.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Disposition: inline\r
+In-Reply-To: <878v44qhop.fsf@nikula.org>\r
+User-Agent: Mutt/ (2012-12-30)\r
+X-Source-IP: acsinet22.oracle.com [141.146.126.238]\r
+Cc: notmuch@notmuchmail.org, Vladimir Marek <vlmarek@volny.cz>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 27 Apr 2013 16:05:49 -0000\r
+\r
+> It's okay to use the result of .c_str() as long as the string object\r
+> stays in scope, and none of the non-const member functions are\r
+> called. Here, I think the problem is that TermIterator's overloaded\r
+> operator*() returns a string object within the if block's scope, and it\r
+> goes immediately out of scope. You could check this by adding\r
+\r
+Right, I overlooked that TermIterator creates temporary string (if I\r
+understand you correctly).\r
+\r
+> \r
+> string s = *i;\r
+>\r
+> in function scope, and replacing (*i) with s in the if block. This might\r
+> also be more obvious than the presented patch, but I think the patch is\r
+> fine too.\r
+\r
+I would prefer my change as it avoids creating another std::string. At\r
+least I think.\r
+\r
+Thank you\r
+-- \r
+ Vlad\r