<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">I've definitely seen code like the
following in various production code bases:<br>
<br>
namespace {<br>
bool global = false;<br>
}<br>
class Foo { <br>
void modify_global() { global = true; }<br>
};<br>
<br>
// usually, there's a layer of indirection (or two, or three) here<br>
((Foo*)NULL)->modify_global();<br>
<br>
<br>
Discussions on StackOverflow seem to clearly indicate that the
above code is undefined. Having said that, I have not tried to
parse apart the actual spec on this one, so I'll leave that
discussion to others. <br>
<br>
If we do decide this is undefined, do we have a general policy on
how to warn about, or under which optimization levels to enable,
such optimizations? If not, it would probably worth some
discussion on what a general policy might look like. <br>
<br>
Philip<br>
<br>
On 11/6/13 4:36 PM, Yin Ma wrote:<br>
</div>
<blockquote
cite="mid:13a401cedb51$720aafe0$56200fa0$@codeaurora.org"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<meta name="Generator" content="Microsoft Word 14 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"\@SimSun";
panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
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:"Calibri","sans-serif";
color:windowtext;}
.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]-->
<div class="WordSection1">
<p class="MsoNormal">Hi,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">For a small case, that calls NULL pointer
function. LLVM explicitly converts<o:p></o:p></p>
<p class="MsoNormal">It to a store because it thinks it is not
reachable like calling undefvalue.<o:p></o:p></p>
<p class="MsoNormal">In InstCombineCalls.cpp:930<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I think it is not a right approach because
calling null pointer function <o:p></o:p></p>
<p class="MsoNormal">Will segfault the program. Converting to a
store will make program pass<o:p></o:p></p>
<p class="MsoNormal">Silently. This changes the behavior of a
program. <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">So we need remove the case if
(isa<ConstantPointerNull>(Callee) at <o:p></o:p></p>
<p class="MsoNormal">InstCombineCalls.cpp:918 and treat calling
Null pointer reachable.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">How do you think? Is there any reason that
we should convert <o:p></o:p></p>
<p class="MsoNormal">a calling null pointer to a store?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Yin <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
</blockquote>
<br>
</body>
</html>