3 ms·
Genuine question, is iterator invalidation still a problem that people can hit with modern C++ constructs? A quick search seems to answer "yes"[1], but I'm not
by estebank 5y ago
Genuine question, is iterator invalidation still a problem that people can hit with modern C++ constructs? A quick search seems to answer "yes"[1], but I'm not involved in writing C++ to evaluate what the common mitigations are.
For what is worth, I believe that 99% of what you can express in one language you can in the other. If you're hitting walls with the borrow checker when writing Rust you always have the options of either using the equivalents of unique_ptr<T> and shared_ptr<T>, or of cloning memory.
> A Rust compiler bug could expose you to a memory fault, in the same way that a C++ library bug could; but the compiler is well exercised and tested, much as is is a mature library.
I'm not sure what this sentence was expressing, but it seems you're implying here that rustc isn't well exercised and tested?
[1]: https://medium.com/@lightcone/iterator-invalidation-in-modern-c-ca0f3c161c5f https://medium.com/@lightcone/iterator-invalidation-in-moder...
- ncmncm 5y agoIterator invalidation, like pointer invalidation, remains a thing. Iterators and pointers are normally treated as ephemeral, except where guarantees are provided. It is hard for me to imagine how "the compiler is well exercised and tested" could be perceived to mean the opposite. Explain?
- estebank 5y ago> It is hard for me to imagine how "the compiler is well exercised and tested" could be perceived to mean the opposite. Explain? I misread it as talking about modern c++ compilers and libraries being well exercised and tested, and contrasting that with rustc.