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

            Bug ID: 70034
           Summary: repetitive -Wvla warning for each non-constant
                    dimension of a VLA
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: trivial
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

G++ issues -Wvla warning for each dimension of a VLA that is not a constant
expression.  It seems that just one warning for the array object would be
sufficient.  (Interestingly, Clang suffers from the same problem.)

$ cat z.c && /home/msebor/build/gcc-trunk-svn/gcc/xgcc
-B/home/msebor/build/gcc-trunk-svn/gcc -S -Wall -Wextra -Wpedantic -o/dev/null
-xc++ z.cvoid foo (int n)
{
  int a [n][n][n];
}
z.c: In function ‘void foo(int)’:
z.c:3:17: warning: ISO C++ forbids variable length array ‘a’ [-Wvla]
   int a [n][n][n];
                 ^
z.c:3:17: warning: ISO C++ forbids variable length array ‘a’ [-Wvla]
z.c:3:17: warning: ISO C++ forbids variable length array ‘a’ [-Wvla]
z.c:3:7: warning: unused variable ‘a’ [-Wunused-variable]
   int a [n][n][n];
       ^

Reply via email to