[Bug c/98536] warning with -Wvla-parameter for unspecified bound getting specified later
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98536 uecker at gcc dot gnu.org changed: What|Removed |Added Known to fail||11.1.0 Target Milestone|--- |14.0 CC||uecker at gcc dot gnu.org Resolution|--- |FIXED Status|UNCONFIRMED |RESOLVED --- Comment #4 from uecker at gcc dot gnu.org --- Fixed on trunk.
[Bug c/98536] warning with -Wvla-parameter for unspecified bound getting specified later
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98536 --- Comment #3 from CVS Commits --- The master branch has been updated by Martin Uecker : https://gcc.gnu.org/g:39f413fc4b6979d194f2f736bd663eb7f5045168 commit r14-3005-g39f413fc4b6979d194f2f736bd663eb7f5045168 Author: Martin Uecker Date: Thu Apr 13 19:35:15 2023 +0200 c: Less warnings for parameters declared as arrays [PR98536] To avoid false positivies, tune the warnings for parameters declared as arrays with size expressions. Do not warn when more bounds are specified in the declaration than before. PR c/98536 gcc/c-family/: * c-warn.cc (warn_parm_array_mismatch): Do not warn if more bounds are specified. gcc/testsuite: * gcc.dg/Wvla-parameter-4.c: Adapt test. * gcc.dg/attr-access-2.c: Adapt test.
[Bug c/98536] warning with -Wvla-parameter for unspecified bound getting specified later
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98536 --- Comment #2 from Martin Uecker --- The whole point of '*' is to have a way to not specify the bound. It is a very explicit way of saying that I can't (or don't want) to specify the bound. In contrast of not specifying anything, i.e. [], which might be careless omission. So in the later case, I think the warning makes sense but for '*' it should not be on by default.
[Bug c/98536] warning with -Wvla-parameter for unspecified bound getting specified later
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98536 Martin Sebor changed: What|Removed |Added Keywords||diagnostic CC||msebor at gcc dot gnu.org --- Comment #1 from Martin Sebor --- The warning in both cases (reproduced below) is to encourage specifying the bounds in declarations and discourage the use of [*]. At some point [*] needs to be replaced by an actual bound so it might as well be done at the point of the declaration where it can be used by tools for bounds checking. I see [*] as analogous to a function without a prototype. Both have some uses that can't be easily achieved by other means but both are dangerous and best avoided. $ gcc -S -Wall pr98536.c pr98536.c:2:17: warning: argument 1 of type ‘double[3]’ declared as an ordinary array [-Wvla-parameter] 2 | void foo(double x[3]) { } | ~~~^~~~ pr98536.c:1:17: note: previously declared as a variable length array ‘double[*]’ 1 | void foo(double x[*]); | ~~~^~~~ pr98536.c:5:17: warning: argument 1 of type ‘double[*]’ declared with 1 unspecified variable bound [-Wvla-parameter] 5 | void bar(double x[*]); | ~~~^~~~ pr98536.c:6:17: note: subsequently declared as ‘double[n]’ with 0 unspecified variable bounds 6 | void bar(double x[n]) { } | ~~~^~~~