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: warning: operation on 'zero' may be undefined


Paul Schlie wrote:
For my own edification, it's not clear to me that the instruction sequence:

   int zero = 125;
   zero = (++zero)%3;

is ambiguous in any way, as I was under the impression that the left hand
side of an assignment expression will be assigned the resulting value of the
evaluation of it's right hand side, which unambiguously logically equivalent
to:

  int zero = 125;
  zero = ((zero = zero + 1) % 3) ;

Where the compiler would hopefully recognize the opportunity to eliminate
the unnecessary intermediate assignment of zero = zero + 1, as zero is not
declared as being volatile, nor implied due to a lack of a sequence point.

What am I missing?
There is a good description at http://www.eskimo.com/~scs/C-faq/s3.html

nathan

--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk



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