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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |msebor at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |msebor at gcc dot 
gnu.org

--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
Isn't the problem that c_getstr(arg2, &len2) sets len2 to 1 instead of 4 (i.e,
sizeof (x)) as the function comment suggests should happen?

/* Return a pointer P to a NUL-terminated string representing the sequence
   of constant characters referred to by SRC (or a subsequence of such
   characters within it if SRC is a reference to a string plus some
   constant offset).  If STRLEN is non-null, store the number of bytes
   in the string constant including the terminating NUL char.  *STRLEN is
   typically strlen(P) + 1 in the absence of embedded NUL characters.  */

const char *
c_getstr (tree src, unsigned HOST_WIDE_INT *strlen /* = NULL */)

If that's what the function is supposed to do (and even if it isn't), using the
name STRLEN for anything that's not actually the result of strlen() is terribly
misleading, practically begging to be misused.  In fact, going back in time, it
looks like starting with r262522 the function did take two pointers: STRLEN for
the string length (i.e., the result of strlen) and STRSIZE for the size, until
r264301 when it was changed to the current form.

Reply via email to