This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: warning: operation on 'zero' may be undefined
- From: Andrew Pinski <pinskia at physics dot uc dot edu>
- To: Paul Schlie <schlie at comcast dot net>
- Cc: <gcc at gcc dot gnu dot org>
- Date: Fri, 1 Oct 2004 10:25:43 -0400
- Subject: Re: warning: operation on 'zero' may be undefined
- References: <BD82DF7C.CD03%schlie@comcast.net>
On Oct 1, 2004, at 10:18 AM, Paul Schlie wrote:
zero = ((zero = zero + 1) % 3) ;
That is still undefined at least according to the C and C++ standards.
We can take it to mean:
zero = zero + 1;
zero = ((zero) % 3) ;
or
old_zero = zero + 1;
zero = ((old_zero) % 3); zero = old_zero;
So the assignment can come in any order unless you have a sequence point
in-between.
Now Java has different rules and acts the way you think it would, left
to
right.
Thanks,
Andrew Pinski