Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. Bug with unique_ptr and /clr code in Visual Studio 2015

Bug with unique_ptr and /clr code in Visual Studio 2015

Scheduled Pinned Locked Moved Managed C++/CLI
visual-studiocsharpc++dotnetperformance
1 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    John Schroedl
    wrote on last edited by
    #1

    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 a unique_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

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups