4 ms·
Would you say library undefined behavior is just a violation of a library invariant? Like `&str` and `String` containing valid UTF-8? I admit that a library in
by _nalply 3y ago
Would you say library undefined behavior is just a violation of a library invariant? Like `&str` and `String` containing valid UTF-8?
I admit that a library invariant is allowed to be violated temporarily under some strict preconditions. One example are bank account money transfers, where the credit and debit don't happen exactly simultaneously. Something similar could happen in a library.
But for language UB this doesn't work. Why? Is it because of compile-time optimizations possibly deleting code restoring the invariant?