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

Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jvdelisle at gcc dot gnu.org

--- Comment #3 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
With the following patch, the fsanitize error goes away in the io_real_boz2
case. With -std=f2003 the case yields an expected runtime error.  It is the
formatting of this error where the -fsanitize does not like referencing a
pointer for some reason.

Index: format.c
===================================================================
--- format.c    (revision 221842)
+++ format.c    (working copy)
@@ -1117,9 +1117,9 @@
 void
 format_error (st_parameter_dt *dtp, const fnode *f, const char *message)
 {
-  int width, i, offset;
+  int width, i, offset, len;
 #define BUFLEN 300
-  char *p, buffer[BUFLEN];
+  char *p, *q, buffer[BUFLEN];
   format_data *fmt = dtp->u.p.fmt;

   if (f != NULL)
@@ -1132,9 +1132,12 @@
   else
     snprintf (buffer, BUFLEN, "%s\n", message);

+  /* Find the length of the format string.  */
+  for (q = p, len = 0; *q; len++, q++);
+
   /* Get the offset into the format string where the error occurred.  */
   offset = dtp->format_len - (fmt->reversion_ok ?
-                  (int) strlen(p) : fmt->format_string_len);
+                  len : fmt->format_string_len);

   width = dtp->format_len;

Reply via email to