The problem is that programmers don’t always do that, either because they are not that experienced or they are in a hurry.
The real danger is when code is long lived and worked on by multiple people. One bad commit after a late night hacking session and now there is a zero day just waiting to be discovered.
Safe languages don’t rule that out but they make it profoundly less likely.
for that matter though I've seen rust programmers put everything in unsafe.
Also, the DEBUG_NEW thing is useless in practice since, from memory, it stops you using placement new, and dependencies typically don't participate, so a zillion unlabeled leaks is the usual result from the common case of you failing to call some dependency's free function.
And the allocation IDs (and therefore _CrtSetBreakAlloc) are pretty worthless in practice for multithreaded programs, because the allocation order isn't deterministic.
I use the LEAK_CHECK_DF flag in the programs I write (and the CHECK_ALWAYS_DF is worth investigating too), but the only point is to indicate whether there are leaks on exit, yes/no. If no, great; if yes, well that's useful information, but the actual output is almost never helpful. (Though occasionally I do somehow introduce a leak from something that happens before the first thread is created.)
Well, unless they are doing something incredibly stupid including stepping over several explicit warnings of "don't do this unless you are very sure about what you are doing".
Auto industry kind of solved this automation mechanism for example with the new high performance Toyota GR Corolla has a new automatic gear transmission that's proven as fast if not faster than the manual version [2]. The same goes to F1, the epitome of car racing performance.
[1] Understanding Memory Management, Part 5: Fighting with Rust (101 comments):
https://news.ycombinator.com/item?id=43882291
[2] 2025 Toyota GR Corolla's New Automatic Gearbox Democratizes Fun:
https://www.caranddriver.com/reviews/a62672128/2025-toyota-g...
I think c++ should keep the good modern things and fork (restart) from there by breaking backwards compatibility, c++23 will be frozen with some fixes.
eptcyka•22h ago
genter•22h ago
YZF•22h ago
EDIT: Safe in the sense you're not writing into memory you don't own, e.g. write after release, buffer overflows etc.
scotty79•21h ago
aquariusDue•21h ago
dmit•21h ago
drivingmenuts•21h ago
I've just saved untold generations from certain calamity.
** 6,000,000 years later **
Butterfly King: This chimpanzee-descended motherfucker ….
airstrike•21h ago
jayd16•21h ago
andrewflnr•21h ago
Arnavion•21h ago
(The only difference is that Rust defaults to moving while C++ defaults to copying, and Rust moves don't leave a moved-out object behind while C++ does, so the dtors in Rust are simpler and called fewer times than the equivalent C++ code.)
dmit•21h ago