This is the mail archive of the gcc-bugs@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]

[Bug middle-end/39867] [4.4/4.5 Regression] Wrong result of conditional operator exp < 2 ? 2U : (unsigned int) exp



------- Comment #3 from bonzini at gnu dot org  2009-04-23 15:22 -------
Created an attachment (id=17684)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17684&action=view)
patch

Bootstrapped but not yet regtested.  Testcase:

/* { 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 (("%u\n", exp < 2 ? 2U : (unsigned int) exp) > 2)
    link_error ();
  return 0;
}


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39867


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