<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Calisto MT";
        panose-1:2 4 6 3 5 5 5 3 3 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calisto MT","serif";
        color:#7030A0;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-family:&quot;Calisto MT&quot;,&quot;serif&quot;;color:#7030A0">Excellent summary!&nbsp; Thanks.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Calisto MT&quot;,&quot;serif&quot;;color:#7030A0"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Calisto MT&quot;,&quot;serif&quot;;color:#7030A0">-- Gaby<o:p></o:p></span></p>
<p class="MsoNormal"><a name="_MailEndCompose"><span style="font-family:&quot;Calisto MT&quot;,&quot;serif&quot;;color:#7030A0"><o:p>&nbsp;</o:p></span></a></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;">From:</span></b><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;"> ub-bounces@open-std.org [mailto:ub-bounces@open-std.org]
<b>On Behalf Of </b>Matt Austern<br>
<b>Sent:</b> Thursday, January 16, 2014 2:41 PM<br>
<b>To:</b> WG21 UB study group<br>
<b>Subject:</b> Re: [ub] type punning through congruent base class?<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<div>
<div>
<div>
<p class="MsoNormal">On Thu, Jan 16, 2014 at 2:21 PM, Jens Maurer &lt;<a href="mailto:Jens.Maurer@gmx.net" target="_blank">Jens.Maurer@gmx.net</a>&gt; wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">On 01/16/2014 11:05 PM, Matt Austern wrote:<br>
&gt; That's an interesting possibility that I hadn't considered. It's definitely appealing in some ways, but I think that it, too, would imply some pretty big surgery in some pretty fundamental parts of the standard. So let's consider the following code snippet:<br>
&gt; &nbsp; struct MyPOD { int x; }; // 1<br>
&gt; &nbsp; void* vp = malloc(sizeof(MyPOD)); // 2<br>
&gt; &nbsp; MyPOD* p1 = static_cast&lt;MyPOD*&gt;(vp); // 3<br>
&gt; &nbsp; MyPOD* p2 = new MyPOD; // 4<br>
&gt;<br>
&gt; So the basic question I'd ask is: after line 4, what are you allowed<br>
&gt; to do with p1 and what are allowed to do with p2, and how do the<br>
&gt; answers differ? We've got a couple of choices.<br>
&gt;<br>
&gt; First choice: we decide that you aren't allowed to do anything that<br>
&gt; involves dereferencing p1, since p1 doesn't point to an object.<o:p></o:p></p>
</div>
<p class="MsoNormal">Please don't confuse &quot;object&quot; with &quot;lifetime&quot;.<br>
<br>
1.8p1 says an object is a region of storage. &nbsp;Both *p1 and<br>
*p2 satisfy that.<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">That's an interesting observation. It's also true, of course, that<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">&nbsp; void* vp = malloc(12);<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">creates a region of storage and thus, by the definition in 1.8p1,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">creates an object. I'm a little reluctant to say that this line<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">creates an object of type T, though, no matter what T is. Maybe<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">we have subtly different concepts of &quot;object&quot;, &quot;object of type T&quot;,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">and &quot;object whose lifetime has begun&quot;. Or maybe we need to<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">make those subtle distinctions even we aren't currently making<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">them.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">&nbsp;<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal"><br>
Further, 3.8p1 seems to say that the lifetime of both *p1 and *p2<br>
has begun.<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">I agree that&nbsp;3.8p1 seems to say that. Not everyone seems to<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">agree that it says that, though; some people also seem to think<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">that even if it does say that, it shouldn't. I sympathize. That<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">reading of&nbsp;3.8p1 has some surprising consequences. (But every<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">proposed alternative I can think of seems to have some<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">surprising consequences too.)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--Matt<o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>