warning: operation on 'zero' may be undefined

Nathan Sidwell nathan@codesourcery.com
Fri Oct 1 16:27:00 GMT 2004


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