This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/81117] Improve buffer overflow checking in strncpy
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 03 Dec 2017 15:18:44 +0000
- Subject: [Bug c/81117] Improve buffer overflow checking in strncpy
- Auto-submitted: auto-generated
- References: <bug-81117-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81117
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=82945
--- Comment #23 from Martin Sebor <msebor at gcc dot gnu.org> ---
I agree that mentioning the attribute in the documentation of the
-Wstringop-truncation option would be helpful. Let me submit a patch with that
change.
I considered having GCC issue a note suggesting the attribute but decided that
using it was sufficiently rare and specialized that it would be a distraction
in most situations. Of the warnings the option found in GCC, GDB, and Glibc,
using the attribute was a solution in just three instances so far, all in
Glibc:
https://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commit;h=7532837d7b03b3ca5b9a63d77a5bd81dd23f3d9c
Using attribute nonstring inappropriately could also lead to more warnings
because it triggers its own checks that aren't suitable for nul-terminated
strings -- see pr82945.