warning: operation on 'zero' may be undefined

Dave Korn dk@artimi.com
Fri Oct 1 17:43:00 GMT 2004


> -----Original Message-----
> From: gcc-owner On Behalf Of Paul Schlie
> Sent: 01 October 2004 16:44

> I guess I naively perceived the precedence rules 
> unambiguously specified
> that the the value of (++zero) % 3 would be evaluated prior to it's
> assignment as % has a higher precedence than =, and 
> correspondingly (++zero)
> was specified to be evaluated prior to % as () has a higher 
> precedence than
> %; as such although zero = ++zero may be ambiguous, zero = 
> (++zero) is not,
> therefore nor would zero = (++zero) % 3; ?
> 
> Thanks, -paul-


  Ah, but precedence != order of evalation.  Consider:

      x = a * b + c;

  The precedence rules say that * has precedence over +; that means, that the
formula is equivalent to (a*b) + c, but not equal to a * (b+c).

  However the compiler is still completely free as to whether it first evaluates
a*b, and then adds c, or whether it first evaluates c, and then adds a*b.

    cheers, 
      DaveK
-- 
Can't think of a witty .sigline today....
 




More information about the Gcc mailing list