]> gcc.gnu.org Git - gcc.git/commit
c: Add Walloc-size to warn about insufficient size in allocations [PR71219]
authorMartin Uecker <uecker@tugraz.at>
Thu, 27 Jul 2023 11:36:05 +0000 (13:36 +0200)
committerMartin Uecker <uecker@tugraz.at>
Wed, 1 Nov 2023 21:35:14 +0000 (22:35 +0100)
commitd880e093d92084f55b10626610ef059fd9194a6a
tree7d70dae90a63ba18a24e8f89ebeed7e1af246baf
parent25f92179dea3080788c83743823c1decd84fee23
c: Add Walloc-size to warn about insufficient size in allocations [PR71219]

Add option Walloc-size that warns about allocations that have
insufficient storage for the target type of the pointer the
storage is assigned to. Added to Wextra.

PR c/71219
gcc:
* doc/invoke.texi: Document -Walloc-size option.

gcc/c-family:

* c.opt (Walloc-size): New option.

gcc/c:
* c-typeck.cc (convert_for_assignment): Add warning.

gcc/testsuite:

* gcc.dg/Walloc-size-1.c: New test.
* gcc.dg/Walloc-size-2.c: New test.
gcc/c-family/c.opt
gcc/c/c-typeck.cc
gcc/doc/invoke.texi
gcc/testsuite/gcc.dg/Walloc-size-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/Walloc-size-2.c [new file with mode: 0644]
This page took 0.065974 seconds and 5 git commands to generate.