Opened 20 years ago
Closed 18 years ago
#114 closed Bugs (Fixed)
VC doesn't produce error no code either
Reported by: | nobody | Owned by: | Peter Dimov |
---|---|---|---|
Milestone: | Component: | smart_ptr | |
Version: | None | Severity: | |
Keywords: | Cc: |
Description
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 <boost/shared_ptr.hpp> class D { /* ... */ }; void test() { D *pD = new D; // ... boost::shared_ptr<D> dPtr; // ... // AFAIK the following should not compile dPtr = pD; // Problem with compiler! // what the developer intended actually was: // dPtr = boost::shared_ptr<D> (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?
Note:
See TracTickets
for help on using tickets.