The following source causes an incorrect warning with gcc 11.1.0 (sorry did not have 11.1.1 available, it's not yet in spack): void a(long send_size_asize, int (*)[send_size_asize]); void a(long send_size_asize, int (*)[send_size_asize]) {} Compiling it with gcc-11.1 -c -Wall -Werror -fsanitize=undefined mini.c results in mini.c:2:30: error: mismatch in bound 1 of argument 2 declared as 'int (*)[(send_size_asize) - 1]' []8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wvla-parameter-Werror=vla-parameter]8;;] 2 | void a(long send_size_asize, int (*)[send_size_asize]) {} | ^~~~~~~~~~~~~~~~~~~~~~~~ mini.c:1:30: note: previously declared as 'int (*)[(send_size_asize) - 1]' 1 | void a(long send_size_asize, int (*)[send_size_asize]); | ^~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors
Confirmed. It looks like an oversight in r12-2329. The following fixes it: diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c index 552a29f9944..7a50baedea9 100644 --- a/gcc/c-family/c-warn.c +++ b/gcc/c-family/c-warn.c @@ -3275,7 +3275,8 @@ warn_parm_ptrarray_mismatch (location_t origloc, tree curparms, tree newparms) /* Move on if the bounds look the same. */ if (!pcurbndpos && !pnewbndpos && curbnd && newbnd - && operand_equal_p (curbnd, newbnd, OEP_LEXICOGRAPHIC)) + && operand_equal_p (curbnd, newbnd, OEP_LEXICOGRAPHIC + | OEP_DECL_NAME)) continue; if ((curbnd && TREE_CODE (curbnd) != INTEGER_CST)
The master branch has been updated by Martin Sebor <msebor@gcc.gnu.org>: https://gcc.gnu.org/g:a0f9a5dcc3bbe6c7de499e17d201d0f2cb512649 commit r12-2541-ga0f9a5dcc3bbe6c7de499e17d201d0f2cb512649 Author: Martin Sebor <msebor@redhat.com> Date: Tue Jul 27 13:51:55 2021 -0600 Use OEP_DECL_NAME when comparing VLA bounds [PR101585]. Resolves: PR c/101585 - Bad interaction of -fsanitize=undefined and -Wvla-parameters gcc/c-family: PR c/101585 * c-warn.c (warn_parm_ptrarray_mismatch): Use OEP_DECL_NAME. gcc/testsuite: PR c/101585 * gcc.dg/Wvla-parameter-13.c: New test.
Fixed in GCC 12. Will backport to GCC 11.
GCC 11.2 is being released, retargeting bugs to GCC 11.3
The releases/gcc-11 branch has been updated by Richard Biener <rguenth@gcc.gnu.org>: https://gcc.gnu.org/g:5446b933bc1e9449aa408eb66c31b6fcdbe74214 commit r11-9788-g5446b933bc1e9449aa408eb66c31b6fcdbe74214 Author: Martin Sebor <msebor@redhat.com> Date: Tue Jul 27 13:51:55 2021 -0600 Use OEP_DECL_NAME when comparing VLA bounds [PR101585]. Resolves: PR c/101585 - Bad interaction of -fsanitize=undefined and -Wvla-parameters gcc/c-family: PR c/101585 * c-warn.c (warn_parm_ptrarray_mismatch): Use OEP_DECL_NAME. gcc/testsuite: PR c/101585 * gcc.dg/Wvla-parameter-13.c: New test. (cherry picked from commit a0f9a5dcc3bbe6c7de499e17d201d0f2cb512649)
Fixed.