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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2018-03-12
     Ever confirmed|0                           |1

--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> ---
I am testing this:

diff --git a/gcc/stmt.c b/gcc/stmt.c
index 457fe7f6f78..3a3ff40b682 100644
--- a/gcc/stmt.c
+++ b/gcc/stmt.c
@@ -222,11 +222,12 @@ parse_output_constraint (const char **constraint_p, int
op
erand_num,
      from and written to.  */
   *is_inout = (*p == '+');

+  size_t c_len = strlen (constraint);
+
   /* Canonicalize the output constraint so that it begins with `='.  */
   if (p != constraint || *is_inout)
     {
       char *buf;
-      size_t c_len = strlen (constraint);

       if (p != constraint)
        warning (0, "output constraint %qc for operand %d "
@@ -247,7 +248,10 @@ parse_output_constraint (const char **constraint_p, int
ope
rand_num,
     }

   /* Loop through the constraint string.  */
-  for (p = constraint + 1; *p; p += CONSTRAINT_LEN (*p, p))
+  const char *constraint_end = constraint + c_len;
+  for (p = constraint + 1;
+       p <= constraint_end && *p;
+       p += CONSTRAINT_LEN (*p, p))
     switch (*p)
       {
       case '+':

Reply via email to