<div dir="ltr">Hi Mudasir<br><div class="gmail_extra"><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><br></div><b>Method #2:</b> Creating Interest from an existing Interest like this:<br><div style="margin-left:40px"><span style="font-family:tahoma,sans-serif">const Name& tempName = "---";<br>Interest tempInterest = Interest(interest.wireEncode()<wbr>);<br>tempInterest.setName(tempName)<wbr>;<br></span></div><br></div><b>My problem:</b><br><div><div>Now, I know Method#2 is the official way that meets my requirements. But the thing is, when I use method#2 it gives error on <span style="font-family:arial,helvetica,sans-serif"><b>findOrInsert</b></span> method in <span style="font-family:arial,helvetica,sans-serif"><b>pit.cpp</b></span> file and I don't understand its reason.<br><div style="margin-left:40px"><span style="font-family:tahoma,sans-serif">auto entry = make_shared<Entry>(interest);</span><br></div></div></div></div></blockquote><div><br><a href="https://github.com/named-data/ndn-cxx/blob/ebfe4a207f658a77b5249cda4bd0bc35ede82066/src/interest.hpp#L64-L65">https://github.com/named-data/ndn-cxx/blob/ebfe4a207f658a77b5249cda4bd0bc35ede82066/src/interest.hpp#L64-L65</a><br><div style="margin-left:40px">In certain contexts that use Interest::shared_from_this(), Interest must be created using `make_shared`. Otherwise, .shared_from_this() will trigger undefined behavior. <br></div><br></div><div>PIT is one of those contexts. So are many other places in NFD.<br></div><div>Thus, you need:<br><span style="font-family:monospace,monospace">auto tempInterest = std::make_shared<Interest>(interest.wireEncode());<br>tempInterest->setName(tempName);</span><br><br></div><div>Yours, Junxiao<br></div></div></div></div>