[PATCH] fix a couple of bugs in const string folding (PR 86532)

Martin Sebor msebor@gmail.com
Tue Jul 17 15:19:00 GMT 2018


My enhancement to extract constant strings out of complex
aggregates committed last week introduced a couple of bugs in
dealing with non-constant indices and offsets.  One of the bugs
was fixed earlier today (PR 86528) but another one remains.  It
causes strlen (among other functions) to incorrectly fold
expressions involving a non-constant index into an array of
strings by treating the index the same as a non-consatnt
offset into it.

The non-constant index should either prevent the folding, or it
needs to handle it differently from an offset.

The attached patch takes the conservative approach of avoiding
the folding in this case.  The remaining changes deal with
the fallout from the fix.

Tested on x86_64-linux.

Martin

-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc-86532.diff
Type: text/x-patch
Size: 13891 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20180717/8a581800/attachment.bin>


More information about the Gcc-patches mailing list