Re: [PATCH] test: Make gen-threads work with python3
[notmuch-archives.git] / 7b / 77097af2ac286d7e167826e742d6ab62927113
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 778A4431FB6\r
6         for <notmuch@notmuchmail.org>; Sat, 27 Apr 2013 08:59:35 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -2.299\r
10 X-Spam-Level: \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
13         autolearn=disabled\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 I7OGM8QcRFdN for <notmuch@notmuchmail.org>;\r
17         Sat, 27 Apr 2013 08:59:35 -0700 (PDT)\r
18 Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81])\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 1E18A431FAE\r
22         for <notmuch@notmuchmail.org>; Sat, 27 Apr 2013 08:59:35 -0700 (PDT)\r
23 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94])\r
24         by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with\r
25         ESMTP id r3RFxWMJ030917\r
26         (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK)\r
27         for <notmuch@notmuchmail.org>; Sat, 27 Apr 2013 15:59:33 GMT\r
28 Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85])\r
29         by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id\r
30         r3RFxW10015168\r
31         (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL)\r
32         for <notmuch@notmuchmail.org>; Sat, 27 Apr 2013 15:59:32 GMT\r
33 Received: from ubhmt103.oracle.com (ubhmt103.oracle.com [156.151.24.8])\r
34         by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id\r
35         r3RFxWDg002993\r
36         for <notmuch@notmuchmail.org>; Sat, 27 Apr 2013 15:59:32 GMT\r
37 Received: from vi64-x3-2e-prg06.cz.oracle.com (/10.163.102.127)\r
38         by default (Oracle Beehive Gateway v4.0)\r
39         with ESMTP ; Sat, 27 Apr 2013 08:59:31 -0700\r
40 Date: Sat, 27 Apr 2013 17:59:22 +0200\r
41 From: Vladimir Marek <Vladimir.Marek@Oracle.COM>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: Re: [PATCH] don't store temporary value returned from c_str()\r
44 Message-ID: <20130427155922.GA17459@vi64-x3-2e-prg06.cz.oracle.com>\r
45 References: <1366405933-17223-1-git-send-email-Vladimir.Marek@oracle.com>\r
46         <m2sj2cjp2b.fsf@guru.guru-group.fi>\r
47         <20130427101134.GI10394@pub.cz.oracle.com>\r
48         <8738ucw5oi.fsf@zancas.localnet>\r
49 MIME-Version: 1.0\r
50 Content-Type: text/plain; charset=utf-8\r
51 Content-Disposition: inline\r
52 In-Reply-To: <8738ucw5oi.fsf@zancas.localnet>\r
53 User-Agent: Mutt/ (2012-12-30)\r
54 X-Source-IP: ucsinet22.oracle.com [156.151.31.94]\r
55 X-BeenThere: notmuch@notmuchmail.org\r
56 X-Mailman-Version: 2.1.13\r
57 Precedence: list\r
58 List-Id: "Use and development of the notmuch mail system."\r
59         <notmuch.notmuchmail.org>\r
60 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
61         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
62 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
63 List-Post: <mailto:notmuch@notmuchmail.org>\r
64 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
65 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
66         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
67 X-List-Received-Date: Sat, 27 Apr 2013 15:59:35 -0000\r
68 \r
69 > > const char*\r
70 > > string::c_str(void) {\r
71 > >     char buf[100];\r
72 > >\r
73 > >     strcpy (buf, this->internal_representation);\r
74 > >     return buf;\r
75 > > }\r
76\r
77 > Isn't that undefined behavior, returning a pointer to a (non-static)\r
78 > local variable?\r
79 \r
80 Right, I was trying to bring up an example and this one is not very\r
81 good. Maybe something like that:\r
82 \r
83 \r
84 const char*\r
85 c_str() {\r
86         vector<char> X(my_string);\r
87         return &X[0];\r
88 };\r
89 \r
90 char buf[];\r
91 strcpy(buf, c_str());\r
92 \r
93 X destructor is called after strcpy is done.\r
94 \r
95 char buf[];\r
96 char *tmp=c_str();\r
97 strcpy(buf, tmp);\r
98 \r
99 X destructor is called before strcpy.\r
100 \r
101 At least this is how I understand it.\r
102 \r
103 -- \r
104         Vlad\r