Re: why is it so ?



"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.
.



Relevant Pages

  • Re: Now do not have "My Pictures" in window when click on start.
    ... I refer to the list on the RHS & not the ones that come up ... through being used on the LHS. ... Prev by Date: ...
    (microsoft.public.windowsxp.general)
  • Re: why is it so ?
    ... > without an intervening sequence point. ... (lhs, rhs) ... Prev by Date: ...
    (comp.lang.c)
  • Operator overloading (== and !=) and null
    ... that handles null on either lhs or rhs. ... Prev by Date: ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: A paradoxical series?
    ... >> Below is a simple paradox based on a discussion in the excellent book ... >> While the LHS is obviously positive, the RHS is negative. ... Prev by Date: ...
    (sci.math)
  • Re: A paradoxical series?
    ... > Below is a simple paradox based on a discussion in the excellent book ... > While the LHS is obviously positive, the RHS is negative. ... Prev by Date: ...
    (sci.math)