This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/68252] regiression left operand of shift expression, while we shift > 0 integer
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 09 Nov 2015 09:16:26 +0000
- Subject: [Bug c++/68252] regiression left operand of shift expression, while we shift > 0 integer
- Auto-submitted: auto-generated
- References: <bug-68252-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68252
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-11-09
Version|unknown |5.2.1
Ever confirmed|0 |1
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Looks like a bogus folding to me (CST << B * CST -> CST' << B).
return -3 << a;
from .original and
int foo (int a)
{
return (1 << a) * -3;
}
On trunk:
/* Fold (a * (1 << b)) into (a << b) */
(simplify
(mult:c @0 (convert? (lshift integer_onep@1 @2)))
(if (! FLOAT_TYPE_P (type)
&& tree_nop_conversion_p (type, TREE_TYPE (@1)))
(lshift @0 @2)))
on the branch this is still in fold-const.c.
Note that I think this undefinedness doesn't buy us anything and that we should
just make sure to not emit bogus ubsan errors or warnings.