This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/39867] [4.4/4.5 Regression] Wrong result of conditional operator exp < 2 ? 2U : (unsigned int) exp
- From: "bonzini at gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Apr 2009 15:22:55 -0000
- Subject: [Bug middle-end/39867] [4.4/4.5 Regression] Wrong result of conditional operator exp < 2 ? 2U : (unsigned int) exp
- References: <bug-39867-6373@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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