[PATCH] handle vla plus offset in strlen (PR 90662)

Martin Sebor msebor@gmail.com
Wed Jun 5 22:51:00 GMT 2019

One of my new tests for the strlen/sprintf integration tripped
over an incomplete handling of VLAs by the strlen pass.  Where
it can determine the length of a substring at some offset with
other kinds of arrays, the pass fails with VLAs because they
are represented as pointers to arrays.

The attached patch adds the missing handling so that code like
the following can be fully folded even for VLAs.

   int f (int n)
     char a[n];
     strcpy (a, "12345");
     if (strlen (&a[2]) != 3)
       abort ();

Tested on x86_64-linux.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc-90662.diff
Type: text/x-patch
Size: 10171 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20190605/e8ded799/attachment.bin>

More information about the Gcc-patches mailing list