Boost C++ Libraries: Ticket #114: VC doesn't produce error no code either https://svn.boost.org/trac10/ticket/114 <pre class="wiki">When Using shared_ptr as shown below, the compiler should not compile but show an error instead. However MS Visual Studio compiles without errors but does not generate any code! The following example shows the problem: #include &lt;boost/shared_ptr.hpp&gt; class D { /* ... */ }; void test() { D *pD = new D; // ... boost::shared_ptr&lt;D&gt; dPtr; // ... // AFAIK the following should not compile dPtr = pD; // Problem with compiler! // what the developer intended actually was: // dPtr = boost::shared_ptr&lt;D&gt; (pD); // which works as expected } Class D dtor is never called and memory leaks. The Visual Studio compiler didn't even create code for the assignment. This is a really dangerous situation, since it is a source of serious bugs which should be avoided during compile time! I really like the shared_ptr, however this compiler problem makes them very risky to use. Looks like the compiler is seriously broken. Is this a known problem? Is there a reasonable workaround? </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/114 Trac 1.4.3 nobody Fri, 27 Sep 2002 13:53:49 GMT <link>https://svn.boost.org/trac10/ticket/114#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/114#comment:1</guid> <description> <pre class="wiki">Logged In: NO After some further research it looks like msvc gets confused by assignment operator template&lt;typename T&gt; class shared_ptr { ... public: ... template&lt;typename Y&gt; shared_ptr &amp; operator=(shared_ptr&lt;Y&gt; const &amp; r) ... If this assignment operator is not declared, then msvc correctly produces an error when compiling dPtr= pD; I locally fixed this by declaring an additional _private_ assignment operator (which does not get implemented). template&lt;typename T&gt; class shared_ptr { private: ... // FIX: this_type &amp;operator=(T* rhs); ... This way dPtr = pD doesn't compile either, which is what I expect. </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Peter Dimov</dc:creator> <pubDate>Tue, 15 Mar 2005 22:49:34 GMT</pubDate> <title>status changed https://svn.boost.org/trac10/ticket/114#comment:2 https://svn.boost.org/trac10/ticket/114#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> </ul> Ticket