<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=us-ascii">
<meta name="Generator" content="Microsoft Word 12 (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:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-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-compose;
        font-family:"Tahoma","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
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="DE" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">Hello UB-Experts,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">as far as I can see the following (static_cast) is UB:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">struct</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF;background:white;mso-highlight:white">B</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"> {<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white"> int</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
i;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">};</span><span style="font-size:9.5pt;font-family:Consolas;color:black"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">struct</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF;background:white;mso-highlight:white">D</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"> : B {<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white"> void</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
foo() { </span><span style="font-size:9.5pt;font-family:Consolas;color:green;background:white;mso-highlight:white">/* access B::i */</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"> }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">};</span><span style="font-size:9.5pt;font-family:Consolas;color:black"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF;background:white;mso-highlight:white">B</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
b;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">static_cast</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"><D&>(b).foo();</span><span style="font-size:9.5pt;font-family:Consolas;color:black"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black">because of [expr.static.cast] clause 11<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">first question: is my assessment of the situation correct or is this use legal?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">if it is not (legal): could we make it legal or would we run afoul of the aliasing rules?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">best regards<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">Fabio<o:p></o:p></span></p>
</div>
<p style="FONT-FAMILY: Tahoma,Verdana,Arial; MARGIN-BOTTOM: 1pt; FONT-SIZE: 10pt">
--<br>
Fabio Fracassi | <a href="mailto:ffracassi@think-cell.com">ffracassi@think-cell.com</a><br>
<span style="FONT-FAMILY: Tahoma,Verdana,Arial; COLOR: #666666; FONT-SIZE: 9pt">Software Engineer</span></p>
<br>
<hr size="1">
<table style="FONT-FAMILY: Tahoma,Verdana,Arial; COLOR: #666666; FONT-SIZE: 9pt" cellspacing="0">
<tbody>
<tr>
<td style="PADDING-RIGHT: 5pt">think-cell Sales GmbH & Co. KG</td>
<td colspan="2"><a href="http://www.think-cell.com/">http://www.think-cell.com</a></td>
</tr>
<tr>
<td>Chausseestr. 8/E</td>
<td>phone / fax</td>
<td>+49 30 666473-10 / -19</td>
</tr>
<tr>
<td>10115 Berlin, Germany</td>
<td style="PADDING-RIGHT: 5pt">US phone / fax</td>
<td>+1 800 891 8091 / +1 212 504 3039</td>
</tr>
<tr>
<td style="PADDING-TOP: 5pt" colspan="3">Amtsgericht Berlin-Charlottenburg, HRA 44531 | European Union VAT Id DE815233792
</td>
</tr>
<tr>
<td colspan="3">General partner: think-cell Operations GmbH | Amtsgericht Berlin-Charlottenburg, HRB 129917</td>
</tr>
<tr>
<td colspan="3">Directors: Dr. Markus Hannebauer, Dr. Arno Schödl </td>
</tr>
</tbody>
</table>
<br>
</body>
</html>