From: Jeff Law <law@redhat.com>
To: Bernd Edlinger <bernd.edlinger@hotmail.de>,
"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
Richard Biener <rguenther@suse.de>,
Martin Sebor <msebor@gmail.com>
Subject: Re: [PATCH] Cleanup strcpy/stpcpy no nul warning code
Date: Tue, 18 Sep 2018 18:55:00 -0000 [thread overview]
Message-ID: <1434c397-fa9d-a439-9ed3-07e96cf374d1@redhat.com> (raw)
In-Reply-To: <VI1PR0701MB286291A978C4E3291AA389C6E41D0@VI1PR0701MB2862.eurprd07.prod.outlook.com>
On 9/18/18 5:44 AM, Bernd Edlinger wrote:
>>
>
> Hmm, you know, I wrote a while ago the following:
> https://gcc.gnu.org/ml/gcc-patches/2018-09/msg00411.html
>
> Where I suggested to change c_strlen parameter nonstr to a
> structure, where additional information could go.
It certainly seems better than continually adding more parameters and/or
having a given parameter have multiple overloaded meanings. We'd fill
in everything we can and let the caller determine what bits they need.
Martin has suggested something similar.
>
> Well, I have the impression that the 6/6 patch should be split
> up in a part that uses c_strlen in its current form, and a
> follow-up patch that adds any additional info.
> I prefer doing things step-by-step, you know.
I'm pretty sure it's not going to be able to use c_strlen in its current
form. There are times when it really wants the length of the string,
even if it's not terminated.
>
> Note that the example given is probably unsafe:
>> T (&b[3][1] + v0, bsz);
>
> This does not pass the check in string_constant because it
> looks like _2 = (char*)&b + _1; _3 = strlen (_2);
> I have no way to prove that v0 is not larger than sizeof (b[3]).
That's OK. The existence of the variable part turns "must" warnings
into "may" warnings precisely because we don't know how v0 impacts things.
>
> By the way test test case for pr87053 is an example
> of a false positive warning (it comes twice even though
> TREE_NO_WARNING is used).
>
> gcc pr87053.c
> pr87053.c: In function 'main':
> pr87053.c:15:26: warning: 'strlen' argument missing terminating nul [-Wstringop-overflow=]
> 15 | if (__builtin_strlen (u.z) != 7)
> | ~^~
> pr87053.c:11:3: note: referenced argument declared here
> 11 | } u = {{"1234", "567"}};
> | ^
> pr87053.c:15:26: warning: 'strlen' argument missing terminating nul [-Wstringop-overflow=]
> 15 | if (__builtin_strlen (u.z) != 7)
> | ~^~
> pr87053.c:11:3: note: referenced argument declared here
> 11 | } u = {{"1234", "567"}};
> | ^
>
> I think the duplicate warnings will not go away unless
> this warning is only diagnosed in the tree-ssa-strlen
> pass instead of the folding code, which happens repeatedly.
Please file a bug. FWIW, I wouldn't necessarily rely on on the strlen
pass not being repeated either.
jeff
next prev parent reply other threads:[~2018-09-18 18:36 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-16 20:05 Bernd Edlinger
2018-09-17 17:35 ` Jeff Law
2018-09-17 18:32 ` Bernd Edlinger
2018-09-17 18:35 ` Jeff Law
2018-09-17 19:18 ` Bernd Edlinger
2018-09-17 23:01 ` Jeff Law
2018-09-18 5:38 ` Jeff Law
2018-09-18 12:06 ` Bernd Edlinger
2018-09-18 18:55 ` Jeff Law [this message]
2018-09-22 18:47 ` Martin Liška
2018-09-23 8:49 ` Martin Liška
2018-09-23 14:35 ` Jeff Law
2018-09-24 18:17 ` Jeff Law
2018-09-24 18:19 ` Bernd Edlinger
2018-09-25 3:19 ` Jeff Law
2018-09-25 22:43 ` Jeff Law
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=1434c397-fa9d-a439-9ed3-07e96cf374d1@redhat.com \
--to=law@redhat.com \
--cc=bernd.edlinger@hotmail.de \
--cc=gcc-patches@gcc.gnu.org \
--cc=msebor@gmail.com \
--cc=rguenther@suse.de \
/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).