[Bug c/44828] possible integer wrong code bug
rguenth at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Tue Jul 6 10:35:00 GMT 2010
------- Comment #3 from rguenth at gcc dot gnu dot org 2010-07-06 10:35 -------
The bug is that we have in .original
{
return si1 * si2;
}
while it should have been
{
return (char)((unsigned char) si1 * (unsigned char) si2);
}
which is premature optimization by convert_to_integer, short-cutting
the correctly implemented fold of (signed char)((int) si1 * (int) si2)
to the above.
Index: gcc/convert.c
===================================================================
--- gcc/convert.c (revision 161840)
+++ gcc/convert.c (working copy)
@@ -774,7 +774,8 @@ convert_to_integer (tree type, tree expr
|| ((!TYPE_OVERFLOW_WRAPS (TREE_TYPE (arg0))
|| !TYPE_OVERFLOW_WRAPS (TREE_TYPE (arg1)))
&& (ex_form == PLUS_EXPR
- || ex_form == MINUS_EXPR)))
+ || ex_form == MINUS_EXPR
+ || ex_form == MULT_EXPR)))
typex = unsigned_type_for (typex);
else
typex = signed_type_for (typex);
fixes this.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |rguenth at gcc dot gnu dot
|dot org |org
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2010-07-06 10:35:15
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44828
More information about the Gcc-bugs
mailing list