Re: why is it so ?
- From: Tim Rentsch <txr@xxxxxxxxxxxxxxxxxxx>
- Date: 22 Jul 2005 11:06:12 -0700
"S.Tobias" <siXtY@xxxxxxxxxxxxxxxxxxxxxxxxxx> writes:
> Robert Gamble <rgamble99@xxxxxxxxx> wrote:
> > S.Tobias wrote:
>
> >> a[i] = one(0 || i++);
>
> > Still has the possibility for undefined behavior, the "0 || i++" could
> > be evaluated followed by i in "a[i]" before the function is called
> > without an intervening sequence point.
>
> I think it can be evaluated in one of the two ways:
>
> (lhs, rhs)
> a[i] , 0 [SEQP] i++ [SEQP] one() , return 1 [SEQP] =
>
> or:
>
> (rhs, lhs)
> 0 [SEQP] i++ [SEQP] one() , return 1 [SEQP] a[i] , =
You missed at least one way:
0 [SEQP] a[i] , i++ [SEQP] one() , return 1 [SEQP] =
This ordering shows how this statement could evoke undefined behavior.
.
- Follow-Ups:
- Re: why is it so ?
- From: S.Tobias
- Re: why is it so ?
- References:
- why is it so ?
- From: junky_fellow
- Re: why is it so ?
- From: Barry Schwarz
- Re: why is it so ?
- From: Eric Sosman
- Re: why is it so ?
- From: Keith Thompson
- Re: why is it so ?
- From: S.Tobias
- Re: why is it so ?
- From: Barry Schwarz
- Re: why is it so ?
- From: S.Tobias
- Re: why is it so ?
- From: Robert Gamble
- Re: why is it so ?
- From: S.Tobias
- why is it so ?
- Prev by Date: Re: C Programming: A Modern Approach - Chapter 15 Exercise 5
- Next by Date: Re: Should function argument be changed in function body?
- Previous by thread: Re: why is it so ?
- Next by thread: Re: why is it so ?
- Index(es):
Relevant Pages
|