<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><BR><DIV><DIV>On Oct 18, 2007, at 10:04 AM, Chris Lattner wrote:</DIV><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV> <BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">If I don't use dyn_cast_or_null(), the following case will bus error. With dyn_cast_or_null(), we assert (missing '@interface NSConstantString').</DIV> </BLOCKQUOTE><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">I don't see how this is any better: you're trading one crash for another.<SPAN class="Apple-converted-space">  </SPAN></DIV></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV>If that's true, then why use asserts at all? From my perspective, we use them because they are helpful during development. Since clang is under active development, I think there is a big difference between an assert crash and a bus error. For me, an assert often has an implied "FIXME"...</DIV><DIV><SPAN class="Apple-style-span"><BR><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">If you did a check and gracefully handled the problem that would be different.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Remember that it should be impossible to trigger asserts.<SPAN class="Apple-converted-space">  </SPAN>It seems like this should turn into a real check with error recovery.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV>Understood. As I said in my previous email, the assert is in place "<SPAN class="Apple-style-span" style="text-decoration: underline;">until we have a better solution to how to integrate NSConstantString</SPAN>". If you'd like me to make this a priority, then I can do so. For now, I'd much prefer to simply add an explicit FIXME to the code. It's your call...</SPAN></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">The third:</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV> <BLOCKQUOTE type="cite"><BLOCKQUOTE type="cite"><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">    </SPAN>ObjcInterfaceDecl *strIFace = dyn_cast_or_null<ObjcInterfaceDecl>(IFace);</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">    </SPAN>assert(strIFace && "missing '@interface NSConstantString'");</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">    </SPAN>Context.setObjcConstantStringInterface(strIFace);</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">   </SPAN>}</DIV> </BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Likewise, using cast<> is more efficient in a non-assert build and is less code.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV>I'll try and improve my casting etiquette:-) I have to admit, there are so many different types of casts (between C++ and llvm) that I don't always take the time to evaluate the best fit. My bad.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>snaroff</DIV><DIV><BR><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">-Chris</DIV> </BLOCKQUOTE></DIV><BR></BODY></HTML>