This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch: don't generate dead bytecode


Per Bothner wrote:

> Folding a binary operator when both operand are constants is presumably
> safe - or are the some traps I'm not aware of? 


Here's a case which we get wrong with -O. Note that if x and y are not 
constant, it works correctly.

public class PR4822
{
  public static void main(String[] args)
  {
    int x = 99;
    int y = 0;

    if ((x = y) == (99 - (y = 99)))
      System.out.println ("OK");
    else
      System.out.println ("FAIL");
  }
}


regards

Bryce.




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]