Re: Multiple Assignment Evaluation Debate
Vladimir S. Oka wrote:[color=blue]
> On Friday 17 March 2006 04:48, ena8t8si@yahoo. com opined (in
> <1142570915.659 187.13920@i39g2 000cwa.googlegr oups.com>):
>[color=green]
> >
> > pete wrote:[color=darkred]
> >> ena8t8si@yahoo. com wrote:
> >> >
> >> > Micah Cowan wrote:
> >> > > Michael Mair <Michael.Mair@i nvalid.invalid> writes:
> >> > >
> >> > > > Richard G. Riley schrieb:
> >> > > > > On 2006-03-12, pete <pfiland@mindsp ring.com> wrote:
> >> > > > >
> >> > > > >> I'm coming around to thinking that 6.5 [#2] is relevant, and
> >> > > > >> that p = p->next = q
> >> > > > >>is undefined, and not just unspecified.
> >> > > > > but
> >> > > > > p=(p->next=q);
> >> > > > > is fine? I hope .
> >> > > >
> >> > > > No. Whether you write
> >> > > > a = b = c;
> >> > > > or
> >> > > > a = (b = c);
> >> > > > does not change anything -- apart from clarifying your intent.
> >> > > > You still are modifying p twice between sequence points
> >> > >
> >> > > Well, no he's not.
> >> > > But he's reading its prior value for purposes other
> >> > > than to determine the value stored, so same deal.
> >> >
> >> > Look again. Reading p is necessary to evaluate p->q = next,
> >>
> >> No, it isn't.
> >> The value of (p->q = next) is (next)[/color]
> >
> > The value of p->q = next is next. But in order to get the
> > value, the assignment p->q = next must _have been
> > evaluated_, which needed both operands. Evaluation includes
> > all the actions in the Semantics paragraph, which includes
> > starting the side effect of storing the value.[/color]
>
> I think pete is right. The compiler _knows_ that the result of (p->q =
> next) _will_be_ next before it even produces any code, and can use that
> knowledge once it does get to producing some.[/color]
You've fallen into the trap of arguing based on what a
compiler might be capable of. Regardless of what the
compiler knows, it's still obliged to produce code that
behaves according to how the Semantics paragraphs and
everything else in the standard says it must.
Vladimir S. Oka wrote:[color=blue]
> On Friday 17 March 2006 04:48, ena8t8si@yahoo. com opined (in
> <1142570915.659 187.13920@i39g2 000cwa.googlegr oups.com>):
>[color=green]
> >
> > pete wrote:[color=darkred]
> >> ena8t8si@yahoo. com wrote:
> >> >
> >> > Micah Cowan wrote:
> >> > > Michael Mair <Michael.Mair@i nvalid.invalid> writes:
> >> > >
> >> > > > Richard G. Riley schrieb:
> >> > > > > On 2006-03-12, pete <pfiland@mindsp ring.com> wrote:
> >> > > > >
> >> > > > >> I'm coming around to thinking that 6.5 [#2] is relevant, and
> >> > > > >> that p = p->next = q
> >> > > > >>is undefined, and not just unspecified.
> >> > > > > but
> >> > > > > p=(p->next=q);
> >> > > > > is fine? I hope .
> >> > > >
> >> > > > No. Whether you write
> >> > > > a = b = c;
> >> > > > or
> >> > > > a = (b = c);
> >> > > > does not change anything -- apart from clarifying your intent.
> >> > > > You still are modifying p twice between sequence points
> >> > >
> >> > > Well, no he's not.
> >> > > But he's reading its prior value for purposes other
> >> > > than to determine the value stored, so same deal.
> >> >
> >> > Look again. Reading p is necessary to evaluate p->q = next,
> >>
> >> No, it isn't.
> >> The value of (p->q = next) is (next)[/color]
> >
> > The value of p->q = next is next. But in order to get the
> > value, the assignment p->q = next must _have been
> > evaluated_, which needed both operands. Evaluation includes
> > all the actions in the Semantics paragraph, which includes
> > starting the side effect of storing the value.[/color]
>
> I think pete is right. The compiler _knows_ that the result of (p->q =
> next) _will_be_ next before it even produces any code, and can use that
> knowledge once it does get to producing some.[/color]
You've fallen into the trap of arguing based on what a
compiler might be capable of. Regardless of what the
compiler knows, it's still obliged to produce code that
behaves according to how the Semantics paragraphs and
everything else in the standard says it must.
Comment