<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Apr 7, 2014 at 12:09 PM, Joerg Sonnenberger <span dir="ltr"><<a href="mailto:joerg@britannica.bec.de" target="_blank">joerg@britannica.bec.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On Mon, Apr 07, 2014 at 08:38:58AM -0600, Richard wrote:<br>
> Oops, meant to send this to the mailing list instead of to Reid<br>
> privately. (Why cc the mailing list instead of just sending to the<br>
> mailing list?)<br>
><br>
> In article <CACs=<a href="mailto:tyJ6zaHeiS0eNhBkdcZE--JY4k7yH9_P1yFbGqod6uymMw@mail.gmail.com">tyJ6zaHeiS0eNhBkdcZE--JY4k7yH9_P1yFbGqod6uymMw@mail.gmail.com</a>>,<br>
>     Reid Kleckner <<a href="mailto:rnk@google.com">rnk@google.com</a>> writes:<br>
><br>
> > Looks like a bug.  This can probably be simplified with C++11.<br>
> ><br>
> > On Fri, Apr 4, 2014 at 10:39 AM, Robison, Arch <<a href="mailto:arch.robison@intel.com">arch.robison@intel.com</a>>wrote:<br>
> ><br>
> > >   for (; I != E; I = ++I) {<br>
> > >       ...<br>
> > >   }<br>
> > ><br>
> > > Is there a reason for writing "I = ++I" instead of "++I" ?<br>
><br>
> I don't see how it's a bug because functionality isn't impacted by<br>
> this.  It's simply a redundant assignment.<br>
<br>
</div>It is a bug as it violates the sequence point rule. One memory location<br>
shall not be modified twice.</blockquote><div><br></div><div>Not in C++11, and (probably) not in C11. The side-effect of pre-increment is sequenced before its value computation, and its value computation is sequenced before the assignment. (C++ doesn't have sequence points any more, and C only has them as a vestigial remnant of the pre-memory-model world.)</div>
</div></div></div>