3 ms·
> C++ will forever let you (and your coworkers, and library code you use/misuse) access memory outside array bounds and dereference pointers to already-freed ob
by pcwalton 11y ago
> C++ will forever let you (and your coworkers, and library code you use/misuse) access memory outside array bounds and dereference pointers to already-freed objects. This extends to C++'s advanced features (such as objects captured by reference in anonymous functions.)
Well, to be fair ISO Core C++ (mentioned in the blog post) with all safety profiles turned on is designed to fix this issue. I have my doubts about whether it'll actually succeed in still being C++ though, as it rules out so much valid modern code (and I also have doubts, or at least unanswered questions, about its soundness/expressiveness).
- lomnakkus 11y agoI hate to sound like a fanboy, but... exactamundo! I'm sure the C++ community will gradually work to address the (huge!) security issues through heroic effort, but it's doubtful that anything meaningful can be achieved when "undefined behavior" remains an acceptable definition of the semantics of an operation. EDIT: Don't get me wrong... I am in awe of the recent efforts of the C++ committee (and co.), and I hope they succeed in this endeavour!
- pcwalton 11y ago> it's doubtful that anything meaningful can be achieved when "undefined behavior" remains an acceptable definition of the semantics of an operation. Well, I should be fair. I may be wrong here, but my understanding of ISO Core C++ plus all safety profiles is that this will no longer be the case: there will be no undefined behavior in this particular dialect of C++, assuming the effort to create this dialect succeeds.
- lomnakkus 11y agoYeah, that's my understanding as well... but I'm skeptical that this is actually possible (within reason) given the history of C++ and the sheer weight of legacy C++ code bases.
- sho_hn 11y agoFew useful codebases are brand new. Or if they are they don't stay new. Weight accumulates and at some point efforts always shift to successfully iterating existing things of value.
- pcwalton 11y agoWhich is the problem with the massive subsetting of the language that ISO Core C++ with all safety profiles turned on performs. It rules out so much existing code that porting will be very expensive. We won't know what the delta is between "migrating to ISO Core C++ with all safety profiles" and "migrating to another, memory-safe language with a good FFI" until ISO Core C++ is complete and widely deployed. My instinct tells me that this delta will not be particularly wide--that is, that porting most existing industry C++ code to totally safe ISO Core C++ will not be much easier than rewriting that code in Go or Swift or whatever. (Look at how long the Python 2 to Python 3 transition has been, and consider that ISO Core C++ is much farther away from industry C++ than Python 3 was from Python 2.) I could be wrong about this, though--we'll have to see.
- lomnakkus 11y agoSure... and that's kind of what I'm both skeptical of (and intrigued by). I'm just waiting for standards-sanctioned A(lgebraic)DT data type support -- it's bound to happen at some point! :)