Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / 9e / df1bcc7b7d5861e2287f2d559ee0c70db1bb67
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 B11ED431FBC\r
6         for <notmuch@notmuchmail.org>; Tue, 30 Apr 2013 01:51:32 -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 1ahaPOuZ2KbI for <notmuch@notmuchmail.org>;\r
17         Tue, 30 Apr 2013 01:51:26 -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 DD646431FAF\r
22         for <notmuch@notmuchmail.org>; Tue, 30 Apr 2013 01:51:26 -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 r3U8pAGp004285\r
26         (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK);\r
27         Tue, 30 Apr 2013 08:51:11 GMT\r
28 Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231])\r
29         by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id\r
30         r3U8p65m016017\r
31         (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL);\r
32         Tue, 30 Apr 2013 08:51:07 GMT\r
33 Received: from abhmt119.oracle.com (abhmt119.oracle.com [141.146.116.71])\r
34         by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id\r
35         r3U8p6U3016009; Tue, 30 Apr 2013 08:51:06 GMT\r
36 Received: from pub.cz.oracle.com (/10.163.101.122)\r
37         by default (Oracle Beehive Gateway v4.0)\r
38         with ESMTP ; Tue, 30 Apr 2013 01:51:06 -0700\r
39 Date: Tue, 30 Apr 2013 10:48:52 +0200\r
40 From: Vladimir Marek <Vladimir.Marek@Oracle.COM>\r
41 To: Kim Minh Kaplan <kimminh.kaplan+nomuch@afnic.fr>\r
42 Subject: Re: [PATCH] don't store temporary value returned from c_str()\r
43 Message-ID: <20130430084852.GA19599@pub.cz.oracle.com>\r
44 Mail-Followup-To: Kim Minh Kaplan <kimminh.kaplan+nomuch@afnic.fr>,\r
45         Tomi Ollila <tomi.ollila@iki.fi>, notmuch@notmuchmail.org,\r
46         Vladimir Marek <vlmarek@volny.cz>\r
47 References: <1366405933-17223-1-git-send-email-Vladimir.Marek@oracle.com>\r
48         <m2sj2cjp2b.fsf@guru.guru-group.fi>\r
49         <20130427101134.GI10394@pub.cz.oracle.com>\r
50         <8761z4h7ih.fsf@kaki.tech.prive.nic.fr>\r
51 MIME-Version: 1.0\r
52 Content-Type: multipart/mixed; boundary="J/dobhs11T7y2rNN"\r
53 Content-Disposition: inline\r
54 Content-Transfer-Encoding: 8bit\r
55 In-Reply-To: <8761z4h7ih.fsf@kaki.tech.prive.nic.fr>\r
56 User-Agent: Mutt/1.5.21 (2010-09-15)\r
57 X-Source-IP: acsinet22.oracle.com [141.146.126.238]\r
58 Cc: Tomi Ollila <tomi.ollila@iki.fi>, notmuch@notmuchmail.org,\r
59         Vladimir Marek <vlmarek@volny.cz>\r
60 X-BeenThere: notmuch@notmuchmail.org\r
61 X-Mailman-Version: 2.1.13\r
62 Precedence: list\r
63 List-Id: "Use and development of the notmuch mail system."\r
64         <notmuch.notmuchmail.org>\r
65 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
66         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
67 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
68 List-Post: <mailto:notmuch@notmuchmail.org>\r
69 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
70 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
71         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
72 X-List-Received-Date: Tue, 30 Apr 2013 08:51:32 -0000\r
73 \r
74 \r
75 --J/dobhs11T7y2rNN\r
76 Content-Type: text/plain; charset=utf-8\r
77 Content-Disposition: inline\r
78 Content-Transfer-Encoding: 8bit\r
79 \r
80 Hi,\r
81 \r
82 Thank you, I found it eventually too. But I wrote little test program\r
83 (attached) which confused me. I haven't had much time to take a look\r
84 into it since weekend.\r
85 \r
86 The idea is to have temporary object where I can detect whether\r
87 destructor was called.\r
88 \r
89 I thought that\r
90 \r
91 printf ("%s\n", s.c_str());\r
92 will print "test"\r
93 \r
94 and\r
95 \r
96 x=s.c_str();\r
97 printf ("%s\n", x);\r
98 \r
99 will print "destroyed"\r
100 \r
101 On my machine both prints "destroyed".\r
102 \r
103 \r
104 I still believe my fix is correct, but I'm not at the position to be\r
105 able to defend it at the moment :)\r
106 \r
107 Thank you\r
108 -- \r
109         Vlad\r
110 \r
111 > The january 2012 working draft: \r
112 > http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3337.pdf\r
113\r
114 >     12.2 Temporary objects [class.temporary]\r
115\r
116 >     1 Temporaries of class type are created in various contexts: binding a\r
117 >     reference to a prvalue (8.5.3), returning a prvalue (6.6.3) […]\r
118\r
119 >     3 When an implementation introduces a temporary object of a class that\r
120 >     has a non-trivial constructor (12.1, 12.8), it shall ensure that a\r
121 >     constructor is called for the temporary object. Similarly, the\r
122 >     destructor shall be called for a temporary with a non-trivial destructor\r
123 >     (12.4). Temporary objects are destroyed as the last step in evaluating\r
124 >     the full-expression (1.9) that (lexically) contains the point where they\r
125 >     were created.\r
126 \r
127 --J/dobhs11T7y2rNN\r
128 Content-Type: text/plain; charset=utf-8\r
129 Content-Disposition: attachment; filename="a.cc"\r
130 \r
131 #include <stdio.h>\r
132 #include <vector>\r
133 #include <string.h>\r
134 \r
135 using namespace std;\r
136 \r
137 class array {\r
138         vector<char> impl;\r
139 \r
140         public:\r
141 \r
142         array(int size):impl(size) { }\r
143         array(array &in):impl(in.impl) { }\r
144 \r
145         char*\r
146         operator[](size_t i) {\r
147                 return &impl[i];\r
148         };\r
149 \r
150         ~array() {\r
151                 strcpy(&impl[0], "destroyed");\r
152         }\r
153 };\r
154 \r
155 class str {\r
156         array tmp;\r
157 \r
158         public:\r
159 \r
160         str(const char *input):tmp(100) {\r
161                 strcpy(tmp[0], input);\r
162         };\r
163 \r
164         const char* c_str() {\r
165                 return (array(tmp))[0];\r
166         };\r
167 };\r
168 \r
169 \r
170 int\r
171 main (int argc, char **argv)\r
172 {\r
173         str s("test");\r
174         const char *x;\r
175         printf ("%s\n", s.c_str());\r
176         x=s.c_str();\r
177         printf ("%s\n", x);\r
178         return 0;\r
179 }\r
180 \r
181 --J/dobhs11T7y2rNN--\r