News for hackers. Stuff that matters.
Re:The Myth of Smart Pointers by Animats on Friday December 01, 2023 @03:39AM (#38484562)
I usually phrase this, when hearing people talk about safety in C++, as the mold coming through the wallpaper. The need to take raw pointers from "smart pointers" keeps coming up, because there are too many C APIs.
Re:The Myth of Smart Pointers by projektfu on Friday December 01, 2023 @06:58PM (#38494272)
It's the wrong abstraction for the use case. In the case of QML, Qt has its own memory management paradigm and you can play along or fight it. If you fight it, you need to know what your code and its code is doing.

I mean, why do people consider C++ to be an advanced-level language? Because it's full of these foot guns. Yet the author is a consultant who seems to work mostly with C++, so presumably they're familiar with the cargo-cult programming style of many entry-level C++ devs and the impedance mismatch between various frameworks.

It's just weird to single out smart pointers as the cause of the problem. In this case, someone made a use-after-free. Maybe it would be a memory leak done another way.

I think the Boehm GC would actually be handling this case pretty well, but C++ people are often allergic to GC, even when it would serve well.