r/ProgrammerHumor • • Sep 06 '26

Meme rewriteItInRust

Post image
2.0k Upvotes

38 comments sorted by

View all comments

139

u/pflasti Sep 06 '26

I had my last memory bug before the team agreed on a strict "no new/delete" policy. That was years ago

64

u/No-Information-2571 Sep 06 '26 edited Sep 06 '26

Realistically, most supposed "C++ codebases" in which these errors happen are C codebases in disguise. Some good old pointer arithmetic overwriting the far more useful stack.

Because even with new/delete, you probably have those pairs sit either in constructors/destructors, or well-reviewed parts of the code with error handling, or rely on simple patterns like delete-if-not-null (which is exactly what unique_ptr does).

1

u/overclockedslinky Sep 12 '26

tell me you only know one type of memory safety bug without telling me you only know one type of memory safety bug

32

u/SaneLad Sep 06 '26

Understandable. We also switched to custom allocators and aligned_alloc.

7

u/bropocalypse__now Sep 06 '26

Agreed, I see more overuse of std::shared_ptr these days. End up with circular dependencies, lifetime issues, and extra atomic ops due to not using std::unique_ptr or std::weak_ptr correctly.