Hi,
I'm sorry. I don't know why the compiler decides to delete the assignment in one case but not the other. I doubt there is a better answer than "it decides to drop it, because it's faster that way" and "it doesn't drop it, because it doesn't realize that it can, for some reason".
However, I also don't understand why it's relevant. Both versions of the code are wrong and buggy. And it turns out that this version of this compiler surfaces the bug in one case, but not the other. A different compiler, or a different version of the same compiler, might surface the bug in neither or both cases instead. So if you are asking because you want to rely on one behavior or the other, you are (IMO) making a mistake - you are introducing compiler-version specific, mysterious bugs. If you are asking because you observe similar effects in a non-buggy program which you are trying to optimize, we should be talking about that non-buggy program instead.