On 12/22/21 11:36, Xi Ruoyao wrote:
On Wed, 2021-12-22 at 11:34 +0100, Adrian Moreno via Gcc-help wrote:
On 12/22/21 11:27, Florian Weimer wrote:
* Adrian Moreno via Gcc-help:
So here I do not know what the compiler would think about "pos" if
it
happens to point to some invalid stack address.
In such cases, the compiler typically assumes that the code in
question
is never executed. This means that the comparison does not need to
be
performed, among other things.
So it wouldn't cause undefined behavior?
It *is* undefined behavior, and the compiler can remove any execution
paths which will eventually hit an undefined behavior.
Thanks for confirming.
--
Adrián Moreno