From: Martin Sebor <msebor@gmail.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [PING #2][PATCH] correct memcmp expansion of constant representations containing embedded nuls (PR 95189)
Date: Mon, 13 Jul 2020 18:06:37 -0600 [thread overview]
Message-ID: <7487f7f3-eacb-1aaa-cf3c-fbe5cb7f98c9@gmail.com> (raw)
In-Reply-To: <223dba96-ca1d-e3de-647f-461c773bf490@gmail.com>
Ping: https://gcc.gnu.org/pipermail/gcc-patches/2020-July/549225.html
On 7/7/20 2:02 PM, Martin Sebor wrote:
> Ping: https://gcc.gnu.org/pipermail/gcc-patches/2020-July/549225.html
>
> On 6/30/20 6:23 PM, Martin Sebor wrote:
>> An enhancement to GCC 10 to improve the expansion of strncmp
>> calls with strings with embedded nuls introduced a regression
>> in similar calls to memcmp. A review of the changes that led
>> up to the regression exposed a number of questionable choices
>> that likely conspired to cause the bug.
>>
>> For example, the name of the function with both the strncmp
>> enhancement as well as the memcmp bug is
>> inline_expand_builtin_string_cmp(). It's easy to assume that
>> the function handles calls to strcmp and strncmp but not also
>> memcmp.
>>
>> Another similar example is the name of the second c_getstr()
>> argument -- strlen -- that doesn't actually store the length
>> of the retrieved string but rather its size in bytes
>> (including any embedded nuls, but excluding those appended
>> implicitly to zero out the remainder of an array the string
>> is stored in, up to the array's size).
>>
>> Yet another example of a dubious choice is string_constant()
>> returning the empty string (i.e., STRING_CST with size 1) for
>> zero initializers of constants of any type (as opposed to one
>> of the same size as the constant object).
>>
>> Besides fixing the memcmp bug the attached patch (hopefully)
>> also rectifies some of the otherwise more or less benign
>> mistakes that precipitated it, mostly by clarifying comments
>> and changing misleading names of functions, their arguments,
>> or local variables.
>>
>> A happy consequence of the fixes is that they improve codegen
>> for calls to memcpy with constants whose representation includes
>> embedded nuls.
>>
>> Tested on x86_64-linux.
>>
>> Martin
>>
>
next prev parent reply other threads:[~2020-07-14 0:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-01 0:23 [PATCH] " Martin Sebor
2020-07-07 20:02 ` Martin Sebor
2020-07-14 0:06 ` Martin Sebor [this message]
2020-07-20 18:43 ` committed] " Martin Sebor
2020-07-22 8:23 ` Rainer Orth
2020-07-22 8:36 ` Iain Sandoe
2020-07-23 20:12 ` Martin Sebor
2020-07-23 20:18 ` H.J. Lu
2020-07-23 23:50 ` Martin Sebor
2020-07-24 2:26 ` H.J. Lu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7487f7f3-eacb-1aaa-cf3c-fbe5cb7f98c9@gmail.com \
--to=msebor@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).