diff options
author | Martin Uecker <uecker@tugraz.at> | 2023-07-27 13:36:05 +0200 |
---|---|---|
committer | Martin Uecker <uecker@tugraz.at> | 2023-11-01 22:35:14 +0100 |
commit | d880e093d92084f55b10626610ef059fd9194a6a (patch) | |
tree | 7d70dae90a63ba18a24e8f89ebeed7e1af246baf /gcc/doc | |
parent | 25f92179dea3080788c83743823c1decd84fee23 (diff) | |
download | gcc-d880e093d92084f55b10626610ef059fd9194a6a.zip gcc-d880e093d92084f55b10626610ef059fd9194a6a.tar.gz gcc-d880e093d92084f55b10626610ef059fd9194a6a.tar.bz2 |
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.
Diffstat (limited to 'gcc/doc')
-rw-r--r-- | gcc/doc/invoke.texi | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 53ae784..6e776a0 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -8138,6 +8138,16 @@ always leads to a call to another @code{cold} function such as wrappers of C++ @code{throw} or fatal error reporting functions leading to @code{abort}. @end table +@opindex Wno-alloc-size +@opindex Walloc-size +@item -Walloc-size +Warn about calls to allocation functions decorated with attribute +@code{alloc_size} that specify insufficient size for the target type of +the pointer the result is assigned to, including those to the built-in +forms of the functions @code{aligned_alloc}, @code{alloca}, +@code{calloc}, +@code{malloc}, and @code{realloc}. + @opindex Wno-alloc-zero @opindex Walloc-zero @item -Walloc-zero |