3 ms·
> even then there aren't many _undefined_ things you can do There's actually plenty of things you can do in an `unsafe` block in Rust that counts as undefined
by kibwen 11y ago
> even then there aren't many _undefined_ things you can do
There's actually plenty of things you can do in an `unsafe` block in Rust that counts as undefined behavior (I don't know how you "explicitly ask for unsafe code" in Ada, but I'm confident the same is true there as well). Some of this falls out of the fact that Rust compiles down to LLVM IR, which itself has undefined behavior, but others are inherent (like demanding the preservation of the aliasing guarantees, as you mentioned).
For anyone curious about seriously using unsafe code in Rust (which is to say, using unsafe code in Rust at all, in any capacity), I recommend reading through the Rustonomicon: http://doc.rust-lang.org/nightly/nomicon/ http://doc.rust-lang.org/nightly/nomicon/
- pjmlp 11y ago> I don't know how you "explicitly ask for unsafe code" in Ada You need to import a virtual package and some times also make use of specific pragmas. Ada, and Modula-3 are very much "into your face" in what concerns unsafe code. For example, if you intend to do a conversion between data types without guarantee that the target can can hold a valid data representation, you need to import Ada.Unchecked_Conversion. And do something like this: http://www.adaic.org/resources/add_content/docs/95style/html/sec_5/5-9-1.html http://www.adaic.org/resources/add_content/docs/95style/html... Same applies to everything else deemed unsafe.