Quantcast
Channel: Intel® Software - Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1175

Issues with std::weak_ptr, Compiler 19.0(2019 Update 5), 19.1 (2020), and Visual Studio 2019 16.4.4

$
0
0

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;
}

AttachmentSize
Downloadimage/pngIntel.png26.95 KB
Downloadimage/pngMSVC.png28.6 KB

TCE Open Date: 

Tuesday, February 18, 2020 - 11:33

Viewing all articles
Browse latest Browse all 1175

Trending Articles