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/61893] Constant folding inhibits trapping with -ftrapv


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)
     {


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