https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101585

            Bug ID: 101585
           Summary: Bad interaction of -fsanitize=undefined and
                    -Wvla-parameters
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jahns at dkrz dot de
  Target Milestone: ---

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

Reply via email to