Path: utzoo!utgpu!watserv1!watmath!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!ira.uka.de!fuchs From: fuchs@it.uka.de (Harald Fuchs) Newsgroups: comp.lang.c++ Subject: Re: Order of evaluation bug in Stroustrup? Message-ID: Date: 29 Nov 90 18:17:26 GMT References: <1160@teslab.lab.OZ> Sender: news@ira.uka.de (USENET News System) Organization: University of Karlsruhe, FRG Lines: 23 andrew@teslab.lab.OZ (Andrew Phillips) writes: >In "The C++ Programming Language" by Bjarne Stroustrup, on page 204, >I found the following which I believe to be a bug according to the >rules of C and C++: > last = last->next = new ... >Since the order of evaluation of subexpressions is undefined it is >unclear whether last in last->next refers to the old value of last or >the newly assigned value of last. Or am I missing something? Yes. You are missing the fact that the assignment operator groups right-to-left. So the execution order is: 1. eval new... 2. eval last->next 3. assign (1) to (2) 4. eval last 5. assign the result of (3) (i.e. (1)) to (4) -- Harald Fuchs ... *gulp*