Bug with unique_ptr and /clr code in Visual Studio 2015
Managed C++/CLI
1
Posts
1
Posters
1
Views
1
Watching
-
FYI - I have found and reported a bug with
std::unique_ptr
when used in code built with /clr in VS 2015. Consider this code:void accept_ownership( std::unique_ptr ptr ) { ... }
void test() {
std::unique_ptr mc = std::make_unique( args );accept_ownership( std::move(mc) );
}When
accept_ownership
is called in C++/CLI code, mc will be destructed and accept_ownership receives aunique_ptr
pointing to freed memory. There will be a double-free at exit as well. I've reported the bug with send-a-frown and it is NOT fixed in the Update 1 RC. Let's hope it's fixed in Update 1 RTM. The code works as expected when not built with /clr. John