News for hackers. Stuff that matters.
Re:Metaclasses: Thoughts on generative C++ by _pmf_ on Friday July 28, 2017 @02:36AM (#14872416)
> It's not simple to write memory safe code in C++, otherwise we would have a lot fewer vulnerabilities in C++ codebases.

Using the STL after using Java collections or Qt collections is a shock. I think there really needs to be a "Safe STL" in addition to "Performant STL" that performs range checks. You simply cannot recommend using the STL for safe code.

Re:Metaclasses: Thoughts on generative C++ by duneroadrunner on Friday July 28, 2017 @03:45AM (#14872670)
> I think there really needs to be a "Safe STL" in addition to "Performant STL" that performs range checks.

SaferCPlusPlus[1] provides compatible, memory-safe versions of the most commonly used STL containers. (The compiler switches mentioned by others add range checking, but do not, for example, catch use-after-free bugs.)

> > It's not simple to write memory safe code in C++, otherwise we would have a lot fewer vulnerabilities in C++ codebases.

Using SaferCPlusPlus, it now is simple to write memory-safe code in C++. And it's not much different from writing traditional (unsafe) C++ code.

[1] shameless plug: https://github.com/duneroadrunner/SaferCPlusPlus

Re:Metaclasses: Thoughts on generative C++ by signa11 on Friday July 28, 2017 @03:10AM (#14872535)
> I think there really needs to be a "Safe STL" in addition to "Performant STL" that performs range checks.

indeed. for gcc, you can compile stuff with '-D_GLIBCXX_DEBUG' to enable random-iterator bound checks. moreover, random-access-iterators do have the 'at(...)' stuff available for bounds checked access to the containers.

but, yeah, a standardized way would be very useful.

Re:Metaclasses: Thoughts on generative C++ by pjmlp on Friday July 28, 2017 @03:14AM (#14872554)
Visual C++ on debug mode also enables iterator validation and bounds checking for arrays and strings.

It is also possible to explicitly enable them in release code.

https://blogs.msdn.microsoft.com/vcblog/2017/06/28/security-...

Re:Metaclasses: Thoughts on generative C++ by zvrba on Saturday July 29, 2017 @01:44AM (#14879722)
> Using the STL after using Java collections or Qt collections is a shock.

Why?

I prefer having a free-standing generic find function as opposed to it being implemented in each and every container. Even better example: copy. You can use it with containers, but also with input/output streams (using stream iterators).

You mentioned safety, is iterator invalidation bothering you?

Re:Metaclasses: Thoughts on generative C++ by nicwilson on Friday July 28, 2017 @05:49AM (#14873107)
You can't do that with C++'s "3-legged" algorithms. the begin - end - begin triplet is missing the second end.