This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PING 2][PATCH] enhance -Wrestrict to handle string built-ins (PR 78918)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]