On 22.11.18 16:19, Steven Schveighoffer wrote:
In terms of language semantics, I don't know what the right answer is.
If we want to say that if an optimizer changes program behavior, the
code must be UB, then this would have to be UB.
But I would prefer saying something like -- if a segfault occurs and the
program continues, the system is in UB-land, but otherwise, it's fine.
If this means an optimized program runs and a non-optimized one crashes,
then that's what it means. I'd be OK with that result. It's like
Schrodinger's segfault!
I don't know what it means in terms of compiler assumptions, so that's
where my ignorance will likely get me in trouble :)
This is called nondeterministic semantics, and it is a good idea if you
want both efficiency and memory safety guarantees, but I don't know how
well our backends would support it.
(However, I think it is necessary anyway, e.g. to give semantics to pure
functions.)