I thought you disliked that essay ![]()
That's all well and good, and I have more sympathy for this view than some on this forum, but given that for Rust no such abstract machine has been formally defined yet, platform details and potential optimisations are the only thing that people can realistically talk about now. And let's face it, most Rust code is going to be compiled by naïve translation to imperative code later transformed by optimisation passes, so the whole 'abstract machine' business is in practice a fancy specification of invariants that all optimisations must uphold.
So I think it'd be nice for a change to have a discussion about what kind of optimisations do we want to support, so that we can finally come up with some sensible semantics. In particular, I'd like a more thorough explanation for the x < 150 || x > 120 example, because I find the concept of a value that defies universal quantifiers quite disturbing. I don't see a reason why I shouldn't consider this example an outright compiler bug. What is the specific sequence of optimisation passes that produces such code? How are their transformations justified?
(By the way, in the C++ example, if I replace a heap allocation with a stack allocation — which is uninitialized all the same — the function is optimised to always return true instead. This only serves to strengthen my 'compiler bug' intuition.)
And one more thing. If we want to discourage talking about target platform details in favour of abstract machine semantics, then the same thing should apply to LLVM intrinsics. Not only because it ties Rust to a particular compiler implementation, which isn't all that rigorously specified anyway, but also for the much more down-to-earth reason that relatively few people are familiar enough with LLVM internals to understand it. When someone tells me 'mem::uninitialized is just undef', I have no idea what is being said. And given the headaches arising from conflicting optimisations mentioned in the post, LLVM people don't necessarily have the best idea either.