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: "Dave Korn" <dk at artimi dot com>
- To: "'Paul Schlie'" <schlie at comcast dot net>,<gcc at gcc dot gnu dot org>
- Date: Fri, 1 Oct 2004 18:13:26 +0100
- Subject: RE: warning: operation on 'zero' may be undefined
> -----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....