[Bug fortran/36197] [4.4 Regressio]: gfortran.dg/initialization_12.f90

hjl dot tools at gmail dot com gcc-bugzilla@gcc.gnu.org
Sat May 10 15:37:00 GMT 2008



------- Comment #3 from hjl dot tools at gmail dot com  2008-05-10 15:36 -------
The bug is in quote_string:

 /* Calculate the length we'll need: a backslash takes two ("\\"),
     non-printable characters take 10 ("\Uxxxxxxxx") and others take 1.  */
  for (p = s, i = 0; i < slength; p++, i++)
    {
      if (*p == '\\')
        len += 2;
      else if (!gfc_wide_is_printable (*p))
        len += 10;
      else
        len++;
    }

  q = res = gfc_getmem (len + 1);
  for (p = s, i = 0; i < slength; p++, i++)
    {
      if (*p == '\\')
        *q++ = '\\', *q++ = '\\';
      else if (!gfc_wide_is_printable (*p))
        {
          sprintf (q, "\\U%08" HOST_WIDE_INT_PRINT "ux",
                   (unsigned HOST_WIDE_INT) *p);
          q += 10;
        }

"\\U%08" takes 11 bytes, not 10, if you count trailing '\0'.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36197



More information about the Gcc-bugs mailing list