Hello,
I got a strange error while using weak_ptr built with Intel Parallel Studio XE C++ 2019 update 4 and 5 embedded in VS2019.
Here is a sample of the code I use to reproduce the bug:
#include <iostream> #include <memory> using namespace std; int main( int argc, char* argv[] ) { shared_ptr<int> sp = make_shared<int>( 42 ); cout << *sp << endl; weak_ptr<int> wp = sp; cout << *wp.lock() << endl; wp.reset(); cout << *sp << endl; return 0; }
The first cout outputs "42" from the shared_ptr as expected;
the second cout outputs "42" from the weak_ptr as expected;
the third cout outputs 0xDDDDDDDD (or decimal equivalent...) rather than "42" showing that the shared_ptr was corrupted by the weak_ptr reset().
I observed this "phenomenon" in 64 bit/Debug only. It works fine in Release and in either Debug or Release in 32 bit. I also noticed that it worked correctly with our old Intel 2018 C++ compiler.
Does someone observe the same thing?