3 ms·
> Neither clang nor g++ does so, even with -Wall. I just checked. How could they? Just by having built-in knowledge of standard library types such as std::vect
by HarHarVeryFunny 3y ago
> Neither clang nor g++ does so, even with -Wall. I just checked. How could they?
Just by having built-in knowledge of standard library types such as std::vector, the same way the compiler has built-in knowledge of some library functions such as C's printf().
I wouldn't expect such policing to be perfect, but the compiler could at least catch simple cases where reference/iterator use follows an invalidating operation in the same function.
Don't get me wrong - I'm not defending C++. It's a beast of a language, and takes a lot of experience and self-discipline to use without creating bugs that are hard to find.
- School-Cotton 3y ago> I'm not defending C++. Right, but you were asking what advantage Rust has over C++, which is what I'm trying to explain. (If you had instead asked what advantage C++ has over Rust, I'd have given a very different answer!) > It's a beast of a language, and takes a lot of experience and self-discipline to use without creating bugs that are hard to find. Rust makes creating a certain class of these hard-to-find bugs much harder.