This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/61893] Constant folding inhibits trapping with -ftrapv
- 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: Fri, 25 Jul 2014 10:36:08 +0000
- Subject: [Bug middle-end/61893] Constant folding inhibits trapping with -ftrapv
- Auto-submitted: auto-generated
- References: <bug-61893-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61893
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed by sth like
Index: fold-const.c
===================================================================
--- fold-const.c (revision 212388)
+++ fold-const.c (working copy)
@@ -1121,7 +1121,12 @@
STRIP_NOPS (arg2);
if (TREE_CODE (arg1) == INTEGER_CST)
- return int_const_binop (code, arg1, arg2);
+ {
+ tree res = int_const_binop (code, arg1, arg2);
+ if (res && TYPE_OVERFLOW_TRAPS (TREE_TYPE (arg1)) && TREE_OVERFLOW
(res))
+ return NULL_TREE;
+ return res;
+ }
if (TREE_CODE (arg1) == REAL_CST)
{