https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92016
Bug ID: 92016 Summary: excess errors in Wstringop-overflow-17.c Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- The recently added gcc.dg/Wstringop-overflow-17.c test shows excess errors: FAIL: gcc.dg/Wstringop-overflow-17.c (test for excess errors) E.g.: https://gcc.gnu.org/ml/gcc-testresults/2019-10/msg00450.html The output shows that the exact same warning is repeated for each past-the-end write by the test (made in a loop). This is most likely the result of the even more recent optimization improvement in r276645 (pr91975). The warning is correct but the output too noisy. It would be much better to emit just a single instance for all the invalid accesses. In function ‘copy_n’, inlined from ‘call_copy_n’ at gcc.dg/Wstringop-overflow-17.c:18:3: gcc.dg/Wstringop-overflow-17.c:9:10: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 9 | *d++ = *s++; | ~~~~~^~~~~~ gcc.dg/Wstringop-overflow-17.c: In function ‘call_copy_n’: gcc.dg/Wstringop-overflow-17.c:17:8: note: destination object declared here 17 | char a[3]; // { dg-message "destination object declared here" } | ^ In function ‘copy_n’, inlined from ‘call_copy_n’ at gcc.dg/Wstringop-overflow-17.c:18:3: gcc.dg/Wstringop-overflow-17.c:9:10: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 9 | *d++ = *s++; | ~~~~~^~~~~~ gcc.dg/Wstringop-overflow-17.c: In function ‘call_copy_n’: gcc.dg/Wstringop-overflow-17.c:17:8: note: destination object declared here 17 | char a[3]; // { dg-message "destination object declared here" } | ^ In function ‘copy_n’, inlined from ‘call_copy_n’ at gcc.dg/Wstringop-overflow-17.c:18:3: gcc.dg/Wstringop-overflow-17.c:9:10: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 9 | *d++ = *s++; | ~~~~~^~~~~~ gcc.dg/Wstringop-overflow-17.c: In function ‘call_copy_n’: gcc.dg/Wstringop-overflow-17.c:17:8: note: destination object declared here 17 | char a[3]; // { dg-message "destination object declared here" } | ^ In function ‘copy_n’, inlined from ‘call_copy_n’ at gcc.dg/Wstringop-overflow-17.c:18:3: gcc.dg/Wstringop-overflow-17.c:9:10: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 9 | *d++ = *s++; | ~~~~~^~~~~~ gcc.dg/Wstringop-overflow-17.c: In function ‘call_copy_n’: gcc.dg/Wstringop-overflow-17.c:17:8: note: destination object declared here 17 | char a[3]; // { dg-message "destination object declared here" } | ^ In function ‘copy_n’, inlined from ‘call_copy_n’ at gcc.dg/Wstringop-overflow-17.c:18:3: gcc.dg/Wstringop-overflow-17.c:10:6: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 10 | *d = 0; // { dg-warning "writing 1 byte into a region of size 0" } | ~~~^~~ gcc.dg/Wstringop-overflow-17.c: In function ‘call_copy_n’: gcc.dg/Wstringop-overflow-17.c:17:8: note: destination object declared here 17 | char a[3]; // { dg-message "destination object declared here" } | ^