I remember that Scott Meyers taught me that
func(shared_ptr(new P), shared_ptr(new Q));
is dangerous, because (if I remember correctly) the order of memory allocation, reference counting (constructing) and assignment to function parameters allows a leak (theoretically?) to appear in rare circumstances. To prevent this one should encapsulate the shared_ptr
in a function call, e.g. in make_shared()
.
func(make_shared<P>(), make_shared<Q>());
Here is some discussion about it, too.
I would like to know if there are (current) compilers in the field, on certain systems that indeed may leave some hole in some error cases? Or are those times gone, or were they only theoretical, anyway?
Most interesting would be know if any of these have that issue:
- g++ 4.x or g++ 2.95, on Linux i386, x64, ARM, m68k or any Windows
- Visual C++ on i368, x64 or ARM
- Clang/LLVM on Linux, or any of its platforms
- How about C++ compilers on/from Sun or IBM, HP-UX?
Has anyone observed this behavior on his specific platform?