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

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



Phil Edwards wrote:

>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.
>  
>
The C code does compile just fine.

>>   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.
>  
>
I use QValueStack from Qt which does return a top value on pop.

Anyway, it is invalid since the second A.pop() can be evaluated *before*
first A.pop(). That (is|was) the problem.

- Adam

-- 
Building your applications one byte at a time
http://www.galacticasoftware.com





Reply to: