[PATCH] fold strncmp of unterminated arrays (PR 92501)

Martin Sebor msebor@gmail.com
Thu Nov 14 17:12:00 GMT 2019


Adding tests for unsafe uses of unterminated constant char arrays
in string functions exposed the limitation in strncmp folding
described in PR 92501: GCC only folds strncmp calls involving
nul-terminated constant strings.

The attached patch improves the folder to also handle unterminated
constant character arrays.  This capability is in turn relied on
for the dependable detection of unsafe uses of unterminated arrays
in strncpy, a patch for which I'm about to post separately.

Tested on x86_64-linux.

Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc-92501.diff
Type: text/x-patch
Size: 8200 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20191114/c0ee62b4/attachment.bin>


More information about the Gcc-patches mailing list