News for hackers. Stuff that matters.
Re:A nice, little known C feature: Static array indices in p... by cmccabe on Wednesday February 20, 2013 @01:39AM (#5249284)
std::vector isn't "safe." If you're using a std::vector::iterator and someone appends to the end of the vector, your iterator may be invalidated. std::string isn't safe either. It's easy to create references to strings that don't exist any more, by returning a const reference to a string and then later deleting the string. smart pointers aren't safe-- partly because of cycles, partly because of references to smart pointers, partly because you inevitably have to convert them to something else to use them. I've been using C++ for years and I've debugged all these problems.
Re:A nice, little known C feature: Static array indices in p... by pjmlp on Wednesday February 20, 2013 @02:48AM (#5249413)
> I've been using C++ for years and I've debugged all these problems.

Me too, my first C++ compiler was Turbo C++ 1.0.

They are a lot safe than using the C direct pointer manipulation idioms that make it so easy to create insecure code that can explode at any moment.

What STL offers might not be 100% as safe as the Pascal family of languages offer among others, but it sure is a way lot better than using plain C idioms.

The problems you describe are quite easy to spot if a static analyzer is made part of the build.