POV-Ray : Newsgroups : povray.off-topic : Teach yourself C++ in 21 days : Re: Days 1-5 Server Time
30 Jul 2024 00:25:57 EDT (-0400)
  Re: Days 1-5  
From: Le Forgeron
Date: 20 Apr 2012 03:20:50
Message: <4f910e52$1@news.povray.org>
Le 20/04/2012 03:56, Darren New a écrit :
> On 4/19/2012 18:38, Alain wrote:
>> Le 2012/04/17 09:40, Warp a écrit :
>>
>>>> is a perfectly valid statement in C++. On the other hand, it also
>>>> means that
>>>
>>>> while (x[i] = y[i--]) ;
>>>
>>>> is perfectly valid. You sick, sick people.
>>>
>>> I think that's Undefined Behavior because the same variable is being
>>> modified and referenced more than once in the same expression.
>>>
>>
>> Nothing undefined here.
> 
> Does it compare x[i] to y[i] or to y[i-1]?  Why do you answer that way?
> 
You missed the point: let's name k the initial value of i;

Would you expect the test to be between:
 x[k] & y[k]
 x[k-1] & y[k]

It cannot be x[k] & y[k-1], per the definition of the post-decrement
operator.

-- 
A good Manager will take you
through the forest, no mater what.
A Leader will take time to climb on a
Tree and say 'This is the wrong forest'.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.