Alain <aze### [at] qwertyorg> wrote:
> >> while (x[i] = y[i--]) ;
> Nothing undefined here.
> It's a simple loop that compare the array x[] and y[] untill it find a
> value that is different.
> You get the value of x[i] and see if it's the same as the value of y[i]
> then you decrement i by one.
> On exit, i will point to the value preceding the first different value.
The compiler is free to decrement 'i' before it evaluates 'x[i]' or
after it. Hence you might get 'x[i]' as it was before the decrement, or
after. (The only thing that is guaranteed is that 'y[i]' is evaluated
before 'i' is decremented.) That's why it's undefined behavior.
--
- Warp
Post a reply to this message
|