False negative: buffer overflow in array parameter

Alejandro Colomar alx@kernel.org
Sun Nov 16 18:35:37 GMT 2025


Hi!

Is there any bug ticket open for this thing?

	alx@devuan:~/tmp$ cat bo.c 
	void
	f(int n, int a[n])
	{
		a[n + 100] = 42;
	}
	alx@devuan:~/tmp$ gcc -Wall -Wextra -O3 -fanalyzer -S bo.c 
	alx@devuan:~/tmp$ /opt/local/gnu/gcc/maxof3/bin/gcc -Wall -Wextra -O3 -fanalyzer -S bo.c 
	alx@devuan:~/tmp$

It's hard to find in bugzilla such common bugs, as there's a lot of
noise.

I expect such code would have a diagnostic, as it seems trivial to
realize that n+100 is >= n.


Have a lovely night!
Alex

-- 
<https://www.alejandro-colomar.es>
Use port 80 (that is, <...:80/>).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20251116/1940e7ed/attachment.sig>


More information about the Gcc-help mailing list