<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 23, 2017, at 6:39 PM, James Dennett <<a href="mailto:james.dennett@gmail.com" class="">james.dennett@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_extra"><div class="gmail_quote">On Thu, Feb 23, 2017 at 4:57 PM, Jonathan Roelofs via cfe-dev<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank" class="">cfe-dev@lists.llvm.org</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><span class=""><br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">   <span class="Apple-converted-space"> </span>const std::shared_ptr<clang::TargetO<wbr class="">ptions> &targetopts =<br class="">         <span class="Apple-converted-space"> </span>std::make_shared<clang::Target<wbr class="">Options>(inst.getTargetOpts())<wbr class="">;<br class=""></blockquote><br class=""></span>This line ^ is extremely suspicious. It makes a shared pointer, takes a *reference* to it, and drops it on the floor. To fix it, get rid of the 'const' and '&' from that line.<br class=""></blockquote><div class=""><br class=""></div><div class="">While I'd drop the '&' for clarity, that's not the bug: the temporary returned by std::make_shared will be lifetime extended here where it's bound (directly) to a reference.</div></div></div></div></div></blockquote><br class=""></div><div>Making that change did not stop the crashes, though I do agree that it's not helpful for clarity.</div><br class=""><div apple-content-edited="true" class="">
--<br class="">Larry Gritz<br class=""><a href="mailto:lg@larrygritz.com" class="">lg@larrygritz.com</a><br class=""><br class="">

</div>
<br class=""></body></html>