On Wed, Apr 27, 2022 at 09:43:59AM +0200, Richard Biener wrote:
> but not any operations on the pointer value (compare, pointer-plus,
> difference, masking, etc.). A simple-minded implementation would
> then be
>
> if ((!gimple_vuse (use_stmt) && warn_dangling_pointer < 3)
> || (maybe && ...
That would consider as memory uses both cases where we actually dereference
the pointer and where we store the pointer in some memory.
But perhaps that would be the goal.
> diff --git a/gcc/gimple-ssa-warn-access.cc b/gcc/gimple-ssa-warn-access.cc
> index 879dbcc1e52..80b5119da7d 100644
> --- a/gcc/gimple-ssa-warn-access.cc
> +++ b/gcc/gimple-ssa-warn-access.cc
> @@ -3923,7 +3923,8 @@ pass_waccess::warn_invalid_pointer (tree ref, gimple
> *use_
> stmt,
> return;
> }
>
> - if ((maybe && warn_dangling_pointer < 2)
> + if (equality
> + || (maybe && warn_dangling_pointer < 2)
> || warning_suppressed_p (use_stmt, OPT_Wdangling_pointer_))
> return;
>
This is fine too with the invoke.texi change and the testcases.
Jakub