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

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
Actually, the memcpy is transformed to MEM_REF and the strlen pass knows how to
deal with a subset of those (small powers of 2).  What it doesn't know how to
do yet is deal with other sizes like in the test case below:

  extern char a5[5];

  int g (void)
  {
    __builtin_memcpy (a5, (char[sizeof a5]){ }, sizeof a5);
    return __builtin_strlen (a5);
  }

which results in

  D.1933 = {};
  MEM <unsigned char[5]> [(char * {ref-all})&a5] = MEM <unsigned char[5]>
[(char * {ref-all})&D.1933];
  _1 = __builtin_strlen (&a5);

and that's not folded yet either.  Handling it is among the outstanding
optimizations mentioned in pr92128.

Reply via email to