warning: operation on 'zero' may be undefined

Steven L. Zook SLZook@Qualstar.com
Fri Oct 1 16:44:00 GMT 2004


Personally I prefer

http://www.eskimo.com/~scs/C-faq/q3.2.html

which I think goes to the heart of the issue of when the increment is allowed to happen in ++zero.

-----Original Message-----
From: gcc-owner@gcc.gnu.org [mailto:gcc-owner@gcc.gnu.org]On Behalf Of
Nathan Sidwell
Sent: Friday, October 01, 2004 9:21 AM
To: Paul Schlie
Cc: gcc@gcc.gnu.org
Subject: 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




More information about the Gcc mailing list