]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fix bogus -Wstringop-overflow warning
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 13 Oct 2022 22:55:40 +0000 (00:55 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Thu, 13 Oct 2022 22:59:31 +0000 (00:59 +0200)
commitc26d335fffc689051ee5826455c9d54d1fcf1816
treee535bd578278e70ec247442af67c9aa835359ede
parent537e08cfad04e79fb97d368e397cfc7e782865ec
Fix bogus -Wstringop-overflow warning

If you compile the testcase with -O2 -fno-inline -Wall, you get:

In function 'process_array3':
cc1: warning: 'process_array4' accessing 4 bytes in a region of size 3 [-
Wstringop-overflow=]
cc1: note: referencing argument 1 of type 'char[4]'
t.c:6:6: note: in a call to function 'process_array4'
    6 | void process_array4 (char a[4], int n)
      |      ^~~~~~~~~~~~~~
cc1: warning: 'process_array4' accessing 4 bytes in a region of size 3 [-
Wstringop-overflow=]
cc1: note: referencing argument 1 of type 'char[4]'
t.c:6:6: note: in a call to function 'process_array4'

That's because the ICF IPA pass has identified the two functions and turned
process_array3 into a wrapper of process_array4.

gcc/
* gimple-ssa-warn-access.cc (pass_waccess::check_call): Return
early for calls made from thunks.

gcc/testsuite/
* gcc.dg/Wstringop-overflow-89.c: New test.
gcc/gimple-ssa-warn-access.cc
gcc/testsuite/gcc.dg/Wstringop-overflow-89.c [new file with mode: 0644]