https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126333
--- Comment #6 from Harald Anlauf <anlauf at gcc dot gnu.org> ---
This one is more subtle, as it uses pointers.
% cat pr126333-z3.f90
subroutine resize (x)
integer, pointer :: x(:)
integer, pointer :: old(:), new(:)
integer :: n
n = size (x)
old => x
allocate (x(2*n))
new => x
new(1:n) = old
deallocate (old)
end
% gfc-17 -Wall pr126333-z3.f90 -c
pr126333-z3.f90:8:9:
8 | new => x
| 1
Warning: Variable »new« defined at (1) but never used
[-Wunused-but-set-variable=]
I think we want to rather check if the pointer was associated.