5 ms·
> I would call C++ a memory safe language C++ is not, in any sense, a memory safe language.
by madmoose 6y ago
> I would call C++ a memory safe language
C++ is not, in any sense, a memory safe language.
- bluGill 6y agoThen you don't know anything about C++, only the C legacy it is built on. Modern C++ has good data structures and good memory management. To be fair actually using those features of C++ instead of the C legacy is still catching on. Most instructors aren't even teaching it. Using C in C++ is like using unsafe everywhere in rust - you can do it, but you lose all the advantages.
- floatboth 6y agoMemory safety is not about what a language has. It's about all the things a language doesn't have, doesn't allow.
- deleted 6y ago[deleted]
- Liquid_Fire 6y agoEven if you stick to "modern C++" and never use C-style pointers, arrays, enums or unions, it is still trivial to have memory errors in C++.
- deleted 6y ago[deleted]
- rcxdude 6y agoThis is a common viewpoint but also wrong. There's plenty of ways to invoke memory unsafety in 'modern' C++: iterator invalidation is probably the biggest source.
- bluGill 6y agoWhile you are technically correct, those who study C++ security note that those are a tiny minority of all security errors. Still an issue, but not nearly as common an issue as the ones that come from the C roots of C++.
- rational_indian 6y agoNo true Scotsman huh? https://en.wikipedia.org/wiki/No_true_Scotsman https://en.wikipedia.org/wiki/No_true_Scotsman Also can you link to an example of this purported memory safe C++ compiler? Please note for an apples to apples comparison it must reject all memory unsafe non-modern C++ constructs.
- mccr8 6y agoIterator invalidation was the cause of a Firefox zero day in 2016. https://bugzilla.mozilla.org/show_bug.cgi?id=1321066 https://bugzilla.mozilla.org/show_bug.cgi?id=1321066
- varajelle 6y agostd::string_view xx = something_that_returns_a_std_string(); use(xx); //oops