Afficher un message
Vieux 13/04/2008, 19h49   #13
Eric Sosman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: `if (!p ? i++ : 0) break;' == `if (!p){ i++; break;}' ?

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
  Réponse avec citation
 
Page generated in 0,05071 seconds with 9 queries