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

            Bug ID: 87052
           Summary: STRING_CST printing incomplete in Gimple dumps
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

STRING_CST nodes with embedded nuls are formatted in Gimple dumps only up to
the first nul.  Characters beyond the first nul are not printed.  This makes
the dumps incomplete (and raises the question of whether the code is even
correct.)  This has recently been exacerbated by transforming braced-list
initialized constant character arrays into STRING_CSTs (r263511).

$ cat f.c && gcc  -O2 -S -Wall -fdump-tree-gimple=/dev/stdout f.c
void f (char *d)
{
  const char a[3] = "\000ab";

  __builtin_strcpy (d, a);
}

void g (char *d)
{
  const char a[] = { 0, 'a', 'b', 'b' };

  __builtin_strcpy (d, a);
}
f (char * d)
{
  const char a[3];

  try
    {
      a = "";
      __builtin_strcpy (d, &a);
    }
  finally
    {
      a = {CLOBBER};
    }
}


g (char * d)
{
  const char a[4];

  try
    {
      a = "";
      __builtin_strcpy (d, &a);
    }
  finally
    {
      a = {CLOBBER};
    }
}

Reply via email to