[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#278081: gcc-3.3: REGRESSION: Doesn't follow precedence



On Sun, Oct 24, 2004 at 03:49:11PM -0500, Adam Majer wrote:
> Daniel Jacobowitz wrote:
> 
> >This isn't a question of precedence, which only affects the way an
> >expression is interpreted.  It's strictly a problem of evaluation
> >order.  Precedence determines how the expression is parsed, i.e.
> >(-X()) + Y() vs (-X() + Y) () an so forth.
> >  
> >
> I guess this is much easier on the compiler. In most cases it can
> optimize the code better than it could do otherwise. For example,
> 
> -sin(5)+sqrt(5) -> sqrt(5)-sin(5)
> 
> Does mess things up for people that think (or thought) that order of
> precedence is equal to order of evaluation. :)

Those folks needed to not sleep through programming class.  :-)  The rules
for C++ have never changed in this regard, and they're the same as in C.

Also, the code wouldn't have compiled in the first place.  Not even in 2.95.

>    A.push( -A.pop() + A.pop());

is invalid, as pop() returns void.  Maybe you were thinking of .top(),
which does return the topmost element, but doesn't remove it from the stack.
You can either remove it with pop() or access it with top(), but not both
in one call.

-- 
Behind everything some further thing is found, forever; thus the tree behind
the bird, stone beneath soil, the sun behind Urth.  Behind our efforts, let
there be found our efforts.
              - Ascian saying, as related by Loyal to the Group of Seventeen



Reply to: