This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug testsuite/83869] [8 regression] c-c++-common/attr-nonstring-3.c fails starting with r256683
- 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: Mon, 15 Jan 2018 21:07:47 +0000
- Subject: [Bug testsuite/83869] [8 regression] c-c++-common/attr-nonstring-3.c fails starting with r256683
- Auto-submitted: auto-generated
- References: <bug-83869-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83869
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Depends on| |82609
--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
The failing test cases are these two:
$ cat -n gcc/testsuite/c-c++-common/attr-nonstring-3.c | grep
"[[:space:]]25[07][[:space:]]"
250 T (stpncpy (arr, str, N + 1)); /* { dg-warning "writing 5
bytes into a region of size 4 overflows " } */
257 T (stpncpy (p->arr, p->str, N + 1)); /* { dg-warning "writing 5
bytes into a region of size 4 overflows" } */
The following test case demonstrates the problem. The root cause is bug 82609:
the extra set of parentheses around the stpncpy call suppresses the middle-end
warnings in C++ (C is unaffected).
$ cat pr83869.C && gcc -O2 -S -Wstringop-overflow pr83869.C
#include <string.h>
char a[4], b[4];
void sink (char*);
void warn_overflow (void)
{
sink (stpncpy (a, b, sizeof a + 1)); // -Wstringop-overflow (good)
}
void bug_82609_missing_warn_overflow (void)
{
sink ((stpncpy (a, b, sizeof a + 1))); // missing -Wstringop-overflow
}
pr83869.C: In function ‘void warn_overflow()’:
pr83869.C:9:8: warning: ‘char* stpncpy(char*, const char*, size_t)’ writing 5
bytes into a region of size 4 overflows the destination [-Wstringop-overflow=]
sink (stpncpy (a, b, sizeof a + 1)); // -Wstringop-overflow (good)
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82609
[Bug 82609] missing -Warrray-bounds on an argument in parentheses