[cfe-dev] [RFC] Control -Wvla for conformant parameters

Hu Jialun via cfe-dev cfe-dev at lists.llvm.org
Mon Oct 4 06:40:24 PDT 2021


Hello,

It appears that -Wvla tends to be used for two different purposes,

- Code compatibility with pre- and post-C99 code
- Good practices since VLA can have security implications

-Wvla seems to only serve the former one satisfactorily now. For the latter 
purpose, conformant array parameters would still generate VLA diagnosis 
although they degrade into pointers and have no runtime implications. There is 
currently no way to inhibit such false positives.

	$ clang -Wvla -x c -std=c99 - <<< "void f(unsigned n, int a[n]);"
	<stdin>:1:26: warning: variable length array used [-Wvla]
	void f(unsigned n, int a[n]);
	                        ^

I propose that a separate warning against conformant parameters be extracted 
from -Wvla, so that it is possible to negate it. I would be more than glad if 
I could attempt to work out the implementation should this proposal be 
accepted.

Best regards,
Hu Jialun




More information about the cfe-dev mailing list