This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PING 2][PATCH] enhance -Wrestrict to handle string built-ins (PR 78918)
- From: Tom de Vries <Tom_deVries at mentor dot com>
- To: Martin Sebor <msebor at gmail dot com>, Jeff Law <law at redhat dot com>, Richard Biener <richard dot guenther at gmail dot com>
- Cc: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 8 Jan 2018 10:32:26 +0100
- Subject: Re: [PING 2][PATCH] enhance -Wrestrict to handle string built-ins (PR 78918)
- Authentication-results: sourceware.org; auth=none
- References: <8a0de82f-d68e-9c37-0406-f216e3f92884@gmail.com> <703424cb-db8c-8aae-9bd2-cece5883a5de@gmail.com> <0266f22c-6ac1-f676-123f-c028905519e5@redhat.com> <d76c8b0b-8fbc-8b4e-fe6d-acdaf9efd81b@gmail.com> <CAFiYyc3xAW=4EeAwqrNRx01_8PTq=a3wdsteqMyx_P2qz+SBRw@mail.gmail.com> <1574f108-5456-711e-6533-73c4711c26f2@gmail.com> <CAFiYyc1Hxfn-8PoTkrsNPSerk-c34deM-zO94if4xVcCxe5kDQ@mail.gmail.com> <40984eff-b156-3315-7bb5-558e9e83bf6c@gmail.com> <ea60148d-4e53-2434-7c9f-c6dd26d3363f@gmail.com> <86344144-d7de-9a92-2e65-9d43536c312b@gmail.com> <11adcf4e-2ed0-c441-2ea7-538fb453b956@gmail.com> <5ffed8d2-4957-898f-590f-b09a3d9ca719@redhat.com> <7b05b1da-da02-1385-5ef6-ba0eee6fc7b1@gmail.com> <d08de941-7697-d1ea-4586-dacd01e53c51@gmail.com> <7a5fae23-f63e-98b5-7368-a7cf992ebe20@redhat.com> <303e3cba-f825-dc90-cf24-01e9e3240192@gmail.com> <b0f49335-e97a-aa27-9169-aa5dfe04a166@gmail.com> <f5945471-3be8-3657-fabc-bd1fedd4c057@redhat.com> <6fedb302-439c-78a5-4772-454b31a0a4f8@gmail.com>
On 12/17/2017 01:01 AM, Martin Sebor wrote:
* c-c++-common/Wrestrict.c: New test.
681 /* The following doesn't overlap but it should trigger -Wstrinop-ovewrflow
682 for writing past the end. */
683 T ("012", a + sizeof a, a);
For nvptx, the warning actually shows up and is classified as excess error:
...
gcc/testsuite/c-c++-common/Wrestrict.c:683:3: warning:
'__builtin_memcpy' writing 4 bytes into a region of size 0 overflows the
destination [-Wstringop-overflow=]
...
760 r = SR (DIFF_MAX - 2, DIFF_MAX - 1);
761 T (8, "012", a + r, a); /* { dg-warning "accessing 4 bytes at offsets \\\[\[0-9\]+, \[0-9\]+] and 0 overlaps" "strcpy" } */
762
Likewise, the warning triggers here:
...
gcc/testsuite/c-c++-common/Wrestrict.c:761:3: warning:
'__builtin_memcpy' writing 4 bytes into a region of size 0 overflows the
destination [-Wstringop-overflow=]
...
>>> * c-c++-common/Warray-bounds-4.c: New test.
66 TM ("0123", "", ma.a5 + i, ma.a5); /* { dg-warning "offset 6 from the object at .ma. is out of the bounds of referenced subobject .a5. with type .char\\\[5]. at offset 0" "strcpy" { xfail *-*-* } } */
67 TM ("", "012345", ma.a7 + i, ma.a7); /* { dg-warning "offset 13 from the object at .ma. is out of the bounds of referenced subobject .\(MA::\)?a7. with type .char ?\\\[7]. at offset 5" } */
And this warning fails to trigger:
...
FAIL: c-c++-common/Warray-bounds-4.c -Wc++-compat (test for warnings,
line 67)
...
Thanks,
- Tom