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

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
           Assignee|unassigned at gcc dot gnu.org      |tkoenig at gcc dot 
gnu.org
             Status|UNCONFIRMED                 |ASSIGNED
           Keywords|                            |diagnostic
   Last reconfirmed|                            |2026-07-20

--- Comment #1 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Things that currently go wrong:

program memain
  implicit none
  character(len=:), allocatable :: c, d
  integer :: n, m
  n = 42
  allocate (character(len=n) :: c)
  read (*,*) c
  print *,c
  ! m = 21
  allocate (character(len=m) :: d) ! { dg-warning "Undefined variable" }
  read (*,*) d
  print *,d
end program memain

issues a warning for n (it should not).

module x
  implicit none
  integer, allocatable, private, dimension(:) :: a, b
  integer, allocatable, public, dimension(:) :: c
contains
  subroutine foo
    print *,a
    print *,b ! { dg-warning "Unallocated variable" }
    print *,c
  end subroutine foo
  subroutine bar
    a = [1,2,3]
  end subroutine bar
end module x

prints a warning for the "print *,c"

And

module x
  implicit none
contains
  function asdf() result(res)
    character(len=1) :: res
    integer :: i
    read (*,*) i
    select case(i)
    case(1)
       res = 'a'
    case(2)
       res = 's'
    case(3)
       res = 'd'
    case(4)
       res = 'f'
    case default
       res = ' '
    end select
  end function asdf
end module x

pretends that i is not used.

Reply via email to