3 ms·
Can you elaborate? Hopefully they don't have straight UB do they?
by dsfuoi 10y ago
Can you elaborate? Hopefully they don't have straight UB do they?
- ktRolster 10y agoHopefully they don't have straight UB do they? Yes, most languages do, unless they are formally defined (ML is formally defined, but most other languages are not. In this book http://www.amazon.com/Masterminds-Programming-Conversations-Creators-Languages/dp/0596515170 http://www.amazon.com/Masterminds-Programming-Conversations-... several of the language creators say that fully defining the language formally is not worth the effort).
- zokier 10y agoWell, Rust for example does not have a formal well-defined behavior to start with, so its kinda fuzzy about UB too. And of course `unsafe` is another story altogether.
- mastax 10y agoCan you elaborate? The rust docs [1] seem to disagree: Unlike C, Undefined Behavior is pretty limited in scope in Rust. All the core language cares about is preventing the following things: - Dereferencing null or dangling pointers - Reading uninitialized memory - Breaking the pointer aliasing rules - Producing invalid primitive values: - dangling/null references - a bool that isn't 0 or 1 - an undefined enum discriminant - a char outside the ranges [0x0, 0xD7FF] and [0xE000, 0x10FFFF] - A non-utf8 str - Unwinding into another language - Causing a data race And all of those things require `unsafe`, so safe rust cannot do any of them (barring compiler or unsafe library or OS bugs). Edit: And I must admit I don't know much about language theory or formal definition, but there is also a self-described formal grammar [2]. [1]: https://doc.rust-lang.org/nomicon/races.html https://doc.rust-lang.org/nomicon/races.html [2]: https://doc.rust-lang.org/grammar.html https://doc.rust-lang.org/grammar.html
- ArkyBeagle 10y agoI think the best way to approach this question is the see CAR Tony Hoare's "Billion Dollar Mistake" talk. A fellow stands up at the end and says, in detail, something that can be summarized as "it's all golden until you invoke the I/O monad."