Re: why is it so ?
- From: "S.Tobias" <siXtY@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: 22 Jul 2005 17:04:31 GMT
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] , =
The first case is more interesting. There's a sequence point
between evaluation of `a[i]' and `i++', so the behaviour is defined.
As for the whole expression, the behaviour is unspecified (I think).
Or is it that lhs and rhs can be evaluated in paralell? Then
there's indeed UB, but then there would be one in `i=f(++i)' too.
--
Stan Tobias
mailx `echo siXtY@xxxxxxxxxxxxxxxxxxxxxxxxxx | sed s/[[:upper:]]//g`
.
- Follow-Ups:
- Re: why is it so ?
- From: Robert Gamble
- Re: why is it so ?
- From: Tim Rentsch
- 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
- why is it so ?
- Prev by Date: Re: Yes/No
- 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
|