by _flux · 1mo ago · 0 comments
https://doc.rust-lang.org/book/ch20-01-unsafe-rust.html
But getting back to the point, the C++ compiler doesn't have a borrow checker, so it can't have a bug in it. So it's on you, as the developer, to take care of all unsoundness.
While in Rust an issue is now filed, and with the fix, every future Rust program gets the fix.
The point of course was not that what you can do, but what you should do. All cases of safe Rust compiler producing unsound code should be fixed, but the same argument is more difficult to make for C++.
Sometimes should might be different of what you must. For example, if your program exhibits unsound behavior in safe Rust (or C++) code, it's probably a lot more practical to just change the program so that it doesn't, instead of updating the compiler, unless you happen to be a Rust compiler developer. But, at the same time, you should file an issue about it.
You can of course find C++ compiler bugs as well, although I expect that to be quite rare nowadays. But the typical case is that if a C++ program exhibits unsound behavior, there is no reasonable compiler fix for it.
Then there's of course Fil-C! This improves the situation greatly by converting most interesting cases of unsound behavior into runtime errors. It seems not everyone is happy with the runtime costs of making this happen, though. And you must compile everything with Fil-C. It doesn't work with Windows or MacOS either.
I simply cannot imagine a situation where you can’t find an alternate solution to a problem with the compiler. Even if the compiler would optimize your intended solution away, you can write an asm! macro.
It sounds to me like you have simply decided that one language cannot do what the other can because you personally would not do it, which is very silly.
If this is not the case then I restate my request for an example, for the third time - an example would prove the point you are not making through explanation.
I hold the argument that if the Rust compiler produces unsound behavior for safe Rust, then the compiler needs to be fixed.