Re: PLEASE HELP ME ! PLEASE



Ben Bacarisse <ben.usenet@xxxxxxxxx> writes:
Richard Heathfield <rjh@xxxxxxxxxxxxxxx> writes:

Guru Jois said:

<snip>

Guru Jois wrote:

a^=b^=a; // could be still better than 3 statements.

<snip>

If I'm wrong, I welcome the comment/objection from experts, b'cause I
always think - " learn from seniors ".

Okay, let's see if that's true.
<snip>
4) the expression you gave is undefined because it violates a "shall"
that is not a constraint: "Between the previous and next sequence point
an object shall have its stored value modified at most once by the
evaluation of an expression. Furthermore, the prior value shall be
accessed only to determine the value to be stored."

I don't follow this last one. I am quite prepared to believe that I
am misunderstanding the phrase, but I am simply not seeing it.

a and b have their stored value modified only once (assuming a sequence
point just prior to this, of course) and to me reading of the prior
value of both a and b are used only to determine the value stored.
What have I missed?

I *think* you're right. Perhaps Richard was thinking of the "correct"
form of the xor swap kludge:

a^=b^=a^=b;

which still has a number of problems.

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.



Relevant Pages

  • Re: Nit-pick non-UB (was Re: about shifting)
    ... Okay, ... the prior value shall be read only to determine the ... possible for the compiler to get it wrong. ... There is no sequence point. ...
    (comp.lang.c)
  • Re: PLEASE HELP ME ! PLEASE
    ... Okay, ... that is not a constraint: "Between the previous and next sequence point ... the prior value shall be ...
    (comp.lang.c)
  • Re: Yet Another Spinoza Challenge
    ... int getc ... Between the previous and next sequence point an object shall have ... its stored value modified at most once by the evaluation of an ... the prior value shall be read only to ...
    (comp.lang.c)
  • Re: Yet Another Spinoza Challenge
    ... int getc ... Between the previous and next sequence point an object shall have ... its stored value modified at most once by the evaluation of an ... the prior value shall be read only to ...
    (comp.lang.c)
  • Re: The danger of classical hypothesis and significance tests [was Re: MADLY AMUSED]
    ... Any constraint on the parameter is in my opinion ... resort to a prior to achieve the same effect. ... Could you briefly explain what you consider a "bayesian bug"? ... a very obscure book that he thinks revolutionizes probability theory ...
    (sci.stat.math)