https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78460

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |memory-hog
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2016-11-22
                 CC|                            |marxin at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Simple test-case:
int foo(char *left, char *right)
{
  return strncmp (left, right, 4294967295U);
}

triggers ICE after I added:
diff --git a/gcc/config/sh/sh-mem.cc b/gcc/config/sh/sh-mem.cc
index f91afa5..018d8bb 100644
--- a/gcc/config/sh/sh-mem.cc
+++ b/gcc/config/sh/sh-mem.cc
@@ -364,6 +364,7 @@ sh_expand_cmpnstr (rtx *operands)
       rtx_code_label *L_end_loop_long = gen_label_rtx ();

       int bytes = INTVAL (operands[3]);
+      gcc_assert (bytes >= 0);
       int witers = bytes / 4;

       if (witers > 1)

Looks 'int' should be replaces with unsigned HOST_WIDE_INT, but still using a
cross compiler, where host is x86_64, I get:

(gdb) p debug_rtx(operands[3])
(const_int -1 [0xffffffffffffffff])
$1 = void

and thus unsigned HOST_WIDE_INT bytes = INTVAL (operands[3]);
is 18446744073709551615 (0xffffffffffffffff).

Apart from that, I wondering why there's no limit, as for instance:
strncmp (left, right, 1000); emits battalion of instructions.

Reply via email to