I remember that Scott Myers taught me that
func(shared_ptr(new P), shared_ptr(new Q));
is dangerous because (if I remember correctly) the order of memory allocation, link counting (building), and assigning functional parameters allows a leak (theoretically?) to occur in rare cases. To prevent this, encapsulate shared_ptr in a function call, for example. in make_shared() .
func(make_shared<P>(), make_shared<Q>());
Here is some discussion about this too.
I would like to know if there are (current) compilers in the field , on some systems , which can actually leave some hole in some cases of errors? Or were those days gone, or were they just theoretical?
The most interesting thing will be to know if any of these problems have:
- 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 for Linux or any of its platforms
- What about C ++ compilers to / from Sun or IBM, HP-UX?
Has anyone watched this behavior on their particular platform?
source share