There seems to be quite a serious issue with std::weak_ptr<> and Intel Compiler 19.0 and 19.1 with Visual Studio 2019.
The problem appears to be that the class _Ref_count_base, which includes the code
_Atomic_counter_t _Uses = 1;
_Atomic_counter_t _Weaks = 1;
Does not appear to be initializing _Weaks to 1 ( when using Intel, not MSVC)
Run this simple program under the debugger and examine the values of _Weaks after the std::weak_ptr<int> has been constructed
Compiled with MSVC and with Intel. Debug at the return statement. You will see _Weaks=2 with MSVC but _Weaks=1 with Intel
int main()
{
std::shared_ptr<int> aStrong = std::make_shared<int>(10);
std::weak_ptr<int> aWeak(aStrong);
return 0;
}
TCE Open Date:
Tuesday, February 18, 2020 - 11:33