lovecreatesbea...@gmail.com wrote:
> On Apr 13, 11:44 pm, Harald van D©¦k <true...@gmail.com> wrote:
>> On Sun, 13 Apr 2008 08:33:07 -0700, lovecreatesbea...@gmail.com wrote:
>>> On Apr 13, 10:57 pm, Eric Sosman <esos...@ieee-dot-org.invalid> wrote:
>>>> lovecreatesbea...@gmail.com wrote:
>>>>> Are the following two lines equal? Suppose the expression i++ doesn't
>>>>> overflow. They behave differently in my code.
>>>>> if (!p ? i++ : 0) break;
>>>>> if (!p){ i++; break;}
>>>> They are not equivalent. Consider the case i==0.
>>> They may be equal when using prefix increment operator.
>> Then consider i == -1.
>>
>
> i may only require unsigned type
Then consider i == (type_of_i)-1.
> I mean these two forms:
>
> /*1*/
> if (!p ? ++i : 0)
> break;
>
>
> /*2*/
> if (!p){
> ++i;
> break;
> }
Not equivalent. Any questions?
--
Eric Sosman
esosman@ieee-dot-org.invalid