violating immutable is undefined behaviour, so the compiler is technically speaking free to assume it never happens. At the very least, neither snippet's result is guaranteed to show a change or not. At the most, literally anything can happen.
I was not aware that you could "violate" immutable. In that case, it's not immutable.