https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56670

--- Comment #12 from Tobias Burnus <burnus at gcc dot gnu.org> ---
character(len=:), allocatable :: aa(:)
character(len=:), pointer :: pp(:)

allocate(character(len=5) :: aa(5), pp(5))
end



gives with  gfortran -Wall

    1 | character(len=:), allocatable :: aa(:)
      |                                      ^
Warning: ‘.aa’ is used uninitialized [-Wuninitialized]
afoo.f90:2:34:

    2 | character(len=:), pointer :: pp(:)
      |                                  ^
Warning: ‘.pp’ is used uninitialized [-Wuninitialized]



The reason is how dtype is initialized:

  D.3965 = (bitsizetype) (sizetype) NON_LVALUE_EXPR <.aa> * 8;
  D.3966 = (sizetype) NON_LVALUE_EXPR <.aa>;
  aa.data = 0B;
  aa.dtype = {.elem_len=(unsigned long) .aa, .rank=1, .type=6};


Later with the alloc, it is correctly set, i.e. it is only an issue for the
initial deallocate state; during allocate:

    .aa = 5;
    aa.dtype = {.elem_len=(unsigned long) .aa, .rank=1, .type=6};


=> Solution: Don't set .elem_len  if the typespec is expr->ts.deferred)

Reply via email to