- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello!
Here is my setup: ICC 16.0 update 3 on Visual Studio 2015. This issue is seen only in 32 bits, not in 64 bits. I observe a strange behaviour that leads to runtime error. Here is a snippet that reproduce the bug:
#include <iostream> #include <memory> using namespace std; void func( shared_ptr<int> p ) { if ( p == nullptr ) { cout << "Is nullptr" << endl; } else { cout << "Is NOT nullptr" << endl; } } int main( int argc, char* argv[] ) { shared_ptr<int> a = nullptr; cout << endl; func( nullptr ); return 0; }
The problem occurs when calling function "func(nullptr)". The passed object is perfect garbage. So it is not nullptr ("else" section) but induces a crash when exiting the function due to invalid destructor execution. On the opposite, shared_ptr "a" in main() is correctly initialized to nullptr. More than that, if I remove the "cout << endl", the bug doesn't occur.
Note again that this code works correctly in 64 bits and also works correctly in both 32/64 bits when compiled with MSVC 14.0 (VS2015). The problem occurs in 32 bits Release and Debug configurations with ICC 16 update 3.
I tried a lot of combinations of compilation options but cannot find one that would solve the problem.
Is it a known bug? Someone else experienced it? I do something wrong? Is there a workaround? Any help will be appreciated! Thank you!
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can reproduce the problem with our ia32 compiler 16.0 update 3 using your program with debug options (/Zi). I tried it with our 17.0 compiler and the problem isn't seen. I know there's at least 1 shared_ptr bug, internal tracking number DPD200407977 reported in 16.0 in this area, there is no workaround unfortunately. Will you be able to update to the 17.0 compiler?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Melanie,
I don't think I'll be able to install 17.0 right now but we are planning to do in (near?) future.
Do you observe the bug with update 4? This would be easier for me to install update 4.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't have update 4 installed, I'll need to find someone who can do that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The code works fine with Intel C++ Compiler 16.0 Update 4 as shown below:
>icl sh.cpp Intel(R) C++ Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 16.0.4.246 Build 20160811 Copyright (C) 1985-2016 Intel Corporation. All rights reserved. sh.cpp Microsoft (R) Incremental Linker Version 14.00.24210.0 Copyright (C) Microsoft Corporation. All rights reserved. -out:sh.exe sh.obj >sh.exe Is nullptr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just checked for IA32 configuration and it works:
>icl sh.cpp Intel(R) C++ Intel(R) 64 Compiler for applications running on IA-32, Version 16.0.4.246 Build 20160811 Copyright (C) 1985-2016 Intel Corporation. All rights reserved. sh.cpp Microsoft (R) Incremental Linker Version 14.00.24210.0 Copyright (C) Microsoft Corporation. All rights reserved. -out:sh.exe sh.obj >sh.exe Is nullptr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Anoop,
First good news! I'll try update 4 ASAP.
Dominique

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page