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. C / C++ / MFC
  4. Myth of a Myth?

Myth of a Myth?

Scheduled Pinned Locked Moved C / C++ / MFC
c++comdebuggingperformancehelp
4 Posts 3 Posters 9 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
    jschell
    wrote on last edited by
    #1

    From CP newsletter The Myth of Smart Pointers – Logikal Blog[^] Basically complaining about what unique_ptr is defined as. Myself reading it and looking at the code it seems to me that the author does not understand the difference between the C++ specification and the C++ compiler/runtime. Which has always been a problem for some people using C/C++ pointers since C (before C++ existed.) The author seems to be suggesting that the specification is guaranteeing that the memory will be collected. But without even reading the spec I seriously doubt it says that. I suspect it is noting that the it might be collected so one should not rely on it. There are multiple other places where one can do similar things and it might or might not work depending on compiler, binary and even execution flow (which is really fun to debug.) Perhaps I am mistaken in what I am reading?

    L Mircea NeacsuM 3 Replies Last reply
    0
    • J jschell

      From CP newsletter The Myth of Smart Pointers – Logikal Blog[^] Basically complaining about what unique_ptr is defined as. Myself reading it and looking at the code it seems to me that the author does not understand the difference between the C++ specification and the C++ compiler/runtime. Which has always been a problem for some people using C/C++ pointers since C (before C++ existed.) The author seems to be suggesting that the specification is guaranteeing that the memory will be collected. But without even reading the spec I seriously doubt it says that. I suspect it is noting that the it might be collected so one should not rely on it. There are multiple other places where one can do similar things and it might or might not work depending on compiler, binary and even execution flow (which is really fun to debug.) Perhaps I am mistaken in what I am reading?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Given the fact that he is breaking all the rules by branching off into QML (whatever that is, and by his own comments something to be avoided) and Javscript, then you cannot expect C++ to know what is happening outside.

      1 Reply Last reply
      0
      • J jschell

        From CP newsletter The Myth of Smart Pointers – Logikal Blog[^] Basically complaining about what unique_ptr is defined as. Myself reading it and looking at the code it seems to me that the author does not understand the difference between the C++ specification and the C++ compiler/runtime. Which has always been a problem for some people using C/C++ pointers since C (before C++ existed.) The author seems to be suggesting that the specification is guaranteeing that the memory will be collected. But without even reading the spec I seriously doubt it says that. I suspect it is noting that the it might be collected so one should not rely on it. There are multiple other places where one can do similar things and it might or might not work depending on compiler, binary and even execution flow (which is really fun to debug.) Perhaps I am mistaken in what I am reading?

        Mircea NeacsuM Offline
        Mircea NeacsuM Offline
        Mircea Neacsu
        wrote on last edited by
        #3

        jschell wrote:

        The author seems to be suggesting that the specification is guaranteeing that the memory will be collected. But without even reading the spec I seriously doubt it says that. I suspect it is noting that the it might be collected so one should not rely on it.

        Of course it doesn't guarantee. Where the memory is coming from and where it is going to, is outside the scope of the language specification. From C++11 to C++23 there was some kind of support for garbage collection using std::declare_reachable, but it was deleted[^].

        Mircea

        1 Reply Last reply
        0
        • J jschell

          From CP newsletter The Myth of Smart Pointers – Logikal Blog[^] Basically complaining about what unique_ptr is defined as. Myself reading it and looking at the code it seems to me that the author does not understand the difference between the C++ specification and the C++ compiler/runtime. Which has always been a problem for some people using C/C++ pointers since C (before C++ existed.) The author seems to be suggesting that the specification is guaranteeing that the memory will be collected. But without even reading the spec I seriously doubt it says that. I suspect it is noting that the it might be collected so one should not rely on it. There are multiple other places where one can do similar things and it might or might not work depending on compiler, binary and even execution flow (which is really fun to debug.) Perhaps I am mistaken in what I am reading?

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          It was a silly article, going out of his way to create a bug and then blaming it on the thing he just intentionally broke. But doing things with C++ that rely on platform/compiler specific details is explicitly allowed, and frequently necessary. The C++ specification alone does not make enough guarantees to result in a useful system - intentionally, so that the details can differ.

          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