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

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



close 278081
thanks

Daniel Jacobowitz wrote:

>On Sun, Oct 24, 2004 at 01:42:02PM -0500, Adam Majer wrote:
>  
>
>>You can rearrange -X+Y, as well as -X()+Y or -X+Y(), but you cannot do
>>this for -X()+Y() unless you can guarantee that X() doesn't depend on
>>Y() and vice-versa.
>>    
>>
>
>Could you quote standard chapter and verse for this?  I believe you are
>incorrect.  While the function calls are sequence points, they are not
>defined to happen in any particular order.
>
>>From ISO C 6.5#3:
>       [#3]  The grouping of operators and operands is indicated by
>       the syntax.  Except as specified later (for the function-
>       call  (),  &&,  ||,  ?:,  and comma operators), the order of
>       evaluation of subexpressions and the  order  in  which  side
>       effects take place are both unspecified.
>
>I don't have ISO C++ handy but I believe it is worded similarly.
>  
>

Well, upstream already marked the bug as "INVALID RESOLVED"...

Anyway, I do remember that the precedence occurs as in order (for above
example)

unary -
+ -

I would expect X() and Y() to be undetermined until actually evaluated.
That is,

-X()+Y()
-x+Y(), where x=evaluated X()
x'+Y(), where x' = -x
x'+y, where y=evaluated Y()

According to upstream (and ISO C), -X()+Y() can be evaluated as,

-X()+Y()
-X()+y
-x+y
x'+y

This essentially means that precedence is not followed if Y depends on X
or vice-versa.

Blah.... Now I have to go and rewrite some code...

- Adam

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





Reply to: