Re: Same code and different result, Why?



On Nov 7, 2:29 pm, "Igor Tandetnik" <itandet...@xxxxxxxx> wrote:

Perhaps a better example might be something like this:

int& set(int& x, int y) { x = y; return x; }

int x = 1, y = 2;
x = x++ + y++;  // undefined
set(x, x++ + y++);  // well-defined

Right, that makes sense (er, as much as any of this does ;-) ) - so
why is the built-in assignment operator not a sequence point, but the
assignment operator for a class is?

-stephen diverdi
-stephen.diverdi@xxxxxxxxx
.



Relevant Pages

  • Re: Accessing result of assignment
    ... the assignment operator *after the next sequence point* causes UB; ... accessing it is part of evaluating memset's arguments; ... The lark is exclusively a Soviet bird. ...
    (comp.lang.c)
  • Re: Accessing result of assignment
    ... > "The order of evaluation of the operands is unspecified. ... > is made to modify the result of an assignment operator or to access it ... > This is pretty common code and obviously not undefined behavior if the ... > assignment operator after the end of statement sequence point as ...
    (comp.lang.c)
  • Re: Undefined behaviour when modifying the result of an assignment operator
    ... >>If an attempt is made to modify ... >>the result of an assignment operator or to access it after the next sequence point, ... Prev by Date: ...
    (comp.lang.c)
  • Re: What is a sequence point?
    ... > I know the basic definition of a sequence point (point where all side ... > "Between the previous and next sequence point an object shall have its ... > stored value modified at most once by the evaluation of an expression. ...
    (comp.lang.c)
  • Re: Same code and different result, Why?
    ... sdiverdi wrote: ... why is the built-in assignment operator not a sequence point, ... the assignment operator for a class is? ...
    (microsoft.public.vc.language)