Hacker News new | ask | show | jobs
by eatitraw 4738 days ago
> RAII doesn't save you from buffer overflows

How do other languages solve this problem?

> or memory leaks when you need an object to live beyond the current scope.

Have you ever heard about smart pointers? They take most pain from dealing with pointers. Managing circular references remains a bit complex though.

1 comments

> How do other languages solve this problem?

Reading or writing past the allocated parts of a buffer is treated as a runtime error, wheras in C/C++ you just end up with corrupted memory.

> Have you ever heard about smart pointers?

Ahh, completely forgot about these. You're right, they're great.