Re:Rust things I miss in C
by Manishearth on Monday February 19, 2018 @11:48AM
(#16413924)
Imagine if dereferencing a null pointer in C was defined to segfault. Currently, it's UB, which means the optimizer assumes it's not null, and when you break that assumption, weird things happen, the least scary of which is a segfault.
This is similar. "program error" means "You're not supposed to do this. But the compiler will not assume that you've not done this; it has your back. If you do this your program will exhibit defined behavior. Perhaps undesired behavior (panicking, or segfaulting), but the behavior will be defined."
How entirely sane and helpful! Thanks for the clarification.
Re:Rust things I miss in C
by steveklabnik on Monday February 19, 2018 @10:17AM
(#16413352)
It's cool, this is the only place where this kind of language is used. So even if you were familiar with Rust, you might not be familiar with this particular corner.
Mostly, it means "this is wrong but it is not undefined behavior".
> Or is it that (2) and (3) are the things that might happen as a result of (1)?
Yes, this.
Can you expand on what that means to someone who hasn't used Rust yet? Does it mean a third thing distinct from (2) and (3)? Or is it that (2) and (3) are the things that might happen as a result of (1)?