Ping: https://gcc.gnu.org/pipermail/gcc-patches/2020-October/555225.html
On 9/30/20 6:14 PM, Martin Sebor wrote:
-Wstring-compare triggers under the same strict conditions as the strcmp/strncmp call is folded into a constant: only when all the uses of the result are [in]equality expressions with zero. However, even when the call cannot be folded into a constant because the result is in addition used in other expressions besides equality to zero, GCC still sets the range of the result to nonzero. So in more complex functions where some of the uses of the same result are in tests for equality to zero and others in other expressions, the warning fails to point out the very mistake it's designed to detect. The attached change enhances the function that determines how the strcmp/strncmp is used to also make it possible to detect the mistakes in the multi-use situations. Tested on x86_64-linux & by building Glibc and Binutils/GDB and confirming it triggers no new warnings. Martin