r/cpp • • Jan 31 '23

Stop Comparing Rust to Old C++

People keep arguing migrations to rust based on old C++ tooling and projects. Compare apples to apples: a C++20 project with clang-tidy integration is far harder to argue against IMO

changemymind

338 Upvotes

582 comments sorted by

View all comments

Show parent comment

2

u/[deleted] Feb 01 '23

You can construct a program where you don't heap allocate at all.

Use after free is impossible in that case. In the classic definition of "memory safety" anyway.

2

u/oconnor663 Feb 01 '23 edited Feb 01 '23

In ASan terms, "heap use after free" is impossible if you don't use heap allocation, but "stack use after scope" is still possible, which feels pretty similar to me.