> In the given example they are not using the shared reference at all during the whole lifetime of the immutable reference and the operation on the immutable one does not change the object at all, so it would be actually safe.
The compiler does not work at that level of resolution. It’s unclear that it should, even for a point query: there is no telling how much a weirdo ISA would bungle that if the two accesses came from different threads, for instance.
> This is the situation where those two rules are a bit too strict and reject a valid program.
Compilers will always, necessarily, reject valid programs. The alternative is to allow invalid programs.