This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libgomp/83106] [8 regression] libgomp/target.c:2671:2: error: ‘strncat’ specified bound 5 equals source length [-Werror=stringop-overflow=]
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 22 Nov 2017 13:11:43 +0000
- Subject: [Bug libgomp/83106] [8 regression] libgomp/target.c:2671:2: error: ‘strncat’ specified bound 5 equals source length [-Werror=stringop-overflow=]
- Auto-submitted: auto-generated
- References: <bug-83106-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83106
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2017-11-22
Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 42678
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42678&action=edit
gcc8-pr83106.patch
I think the warning is just bogus for strncat. Unlike strncpy, which is weird,
sometimes doesn't terminate, sometimes unnecessarily fills with zeros and the
third argument represents the size of the destination (so indeed specifying the
size based on strlen of the source might be a bug), strncat does something
different, the third argument is the max number of chars to take from the src
string; and strncat always terminates. So, passing strlen (src) as third
argument is nothing problematic, it is just another way of specifying strcat,
or
using something strlen based is sane too (both smaller or larger).
That said, the code in target.c is ugly and relies on tree-ssa-strlen.c pass to
fix the mess up, so I'll test and commit the attached patch.