This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GCC 4.3.2 bug (was: Illegal subtraction in tmp-d ive_1.s)‏


2009/4/19 Jason Mancini <jayrusman@hotmail.com>:
>
>> Vincent Lefevre ?writes:
>> ? ?while ((*(q++))-- == 0) ;
>
> Is that defined and legal?? ?Is q incremented before or after *q is decremented? ?They are both post operators!
> Jason Mancini

It's defined and legal (so long as q != &q, which might well be
guaranteed by the type system for an incrementable q -- it's late, and
I might be missing a counterexample to that).  The order of the
increment/decrement makes no difference except in the pathological
case where they attempt to change the same object (and in that case,
the behavior is undefined).

Note: the decrement is done to *initial_value_of_q, as q++ evaluates
to a copy of q's initial value.  q could even be incremented before
that, so long as the decrement still applies to *initial_value_of_q.
All of this assumes the absence of "volatile", of course.

-- James


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]