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] fix pr39867, wrong folding to MAX_EXPR


> Why the "%u\n", ? ?Doesn't make any difference, IMHO should be left out.
> Also, why not test != 2, to verify that the result of the expression isn't
> say signed -1?

Agreed.  The %u was just an editing wart (I first removed 'printf
("%u\n", ' then realized I needed the parenthesis and left in the
first argument to printf as well).

I checked this new testcase with an existing compiler and it fails,
while it passes with the patch:

/* { dg-do link } */
/* { dg-options "-O2" } */

int main (void)
{
  int exp = -1;
  /* Wrong folding of the LHS to an unsigned MAX leads to 4294967295 != 2.  */
  if ((exp < 2 ? 2U : (unsigned int) exp) != 2)
    link_error ();
  return 0;
}

Paolo


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