--- /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 778A4431FB6\r
+ for <notmuch@notmuchmail.org>; Sat, 27 Apr 2013 08:59:35 -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 I7OGM8QcRFdN for <notmuch@notmuchmail.org>;\r
+ Sat, 27 Apr 2013 08:59:35 -0700 (PDT)\r
+Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81])\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 1E18A431FAE\r
+ for <notmuch@notmuchmail.org>; Sat, 27 Apr 2013 08:59:35 -0700 (PDT)\r
+Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94])\r
+ by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with\r
+ ESMTP id r3RFxWMJ030917\r
+ (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK)\r
+ for <notmuch@notmuchmail.org>; Sat, 27 Apr 2013 15:59:33 GMT\r
+Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85])\r
+ by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id\r
+ r3RFxW10015168\r
+ (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL)\r
+ for <notmuch@notmuchmail.org>; Sat, 27 Apr 2013 15:59:32 GMT\r
+Received: from ubhmt103.oracle.com (ubhmt103.oracle.com [156.151.24.8])\r
+ by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id\r
+ r3RFxWDg002993\r
+ for <notmuch@notmuchmail.org>; Sat, 27 Apr 2013 15:59:32 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 08:59:31 -0700\r
+Date: Sat, 27 Apr 2013 17:59:22 +0200\r
+From: Vladimir Marek <Vladimir.Marek@Oracle.COM>\r
+To: notmuch@notmuchmail.org\r
+Subject: Re: [PATCH] don't store temporary value returned from c_str()\r
+Message-ID: <20130427155922.GA17459@vi64-x3-2e-prg06.cz.oracle.com>\r
+References: <1366405933-17223-1-git-send-email-Vladimir.Marek@oracle.com>\r
+ <m2sj2cjp2b.fsf@guru.guru-group.fi>\r
+ <20130427101134.GI10394@pub.cz.oracle.com>\r
+ <8738ucw5oi.fsf@zancas.localnet>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Disposition: inline\r
+In-Reply-To: <8738ucw5oi.fsf@zancas.localnet>\r
+User-Agent: Mutt/ (2012-12-30)\r
+X-Source-IP: ucsinet22.oracle.com [156.151.31.94]\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 15:59:35 -0000\r
+\r
+> > const char*\r
+> > string::c_str(void) {\r
+> > char buf[100];\r
+> >\r
+> > strcpy (buf, this->internal_representation);\r
+> > return buf;\r
+> > }\r
+> \r
+> Isn't that undefined behavior, returning a pointer to a (non-static)\r
+> local variable?\r
+\r
+Right, I was trying to bring up an example and this one is not very\r
+good. Maybe something like that:\r
+\r
+\r
+const char*\r
+c_str() {\r
+ vector<char> X(my_string);\r
+ return &X[0];\r
+};\r
+\r
+char buf[];\r
+strcpy(buf, c_str());\r
+\r
+X destructor is called after strcpy is done.\r
+\r
+char buf[];\r
+char *tmp=c_str();\r
+strcpy(buf, tmp);\r
+\r
+X destructor is called before strcpy.\r
+\r
+At least this is how I understand it.\r
+\r
+-- \r
+ Vlad\r