public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/64120] New: [F03] Wrong handling of allocatable character string
@ 2014-11-30  9:29 fxcoudert at gcc dot gnu.org
  2014-11-30  9:30 ` [Bug fortran/64120] " fxcoudert at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2014-11-30  9:29 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 64120
           Summary: [F03] Wrong handling of allocatable character string
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fxcoudert at gcc dot gnu.org

The following code shows allocatable character does not work as it should:

   call g(1)
contains
  subroutine g(x)
      integer :: x
      character(len=x), allocatable :: s
      allocate(s)
      write(*,*) x, len(s)
  end subroutine
end


It should output "1 1" but outputs "1 0". The tree dump shows that the argument
x is never used in the string allocation.


A longer testcase, including SAVE (which seems also mishandled, but it is
probably linked to this issue):

program test
   logical :: L
   L = g(1)
   write(*,*) L
   L = g(2)
   write(*,*) L
contains
  logical function g(x)
      integer :: x
      character(len=x), allocatable :: s
      save
      if(.NOT.allocated(s)) then
        allocate(s)
        g = .FALSE.
      else
        g = .TRUE.
      end if
      write(*,*) len(s)
  end function g
end


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-07-13 21:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-30  9:29 [Bug fortran/64120] New: [F03] Wrong handling of allocatable character string fxcoudert at gcc dot gnu.org
2014-11-30  9:30 ` [Bug fortran/64120] " fxcoudert at gcc dot gnu.org
2014-11-30 11:44 ` dominiq at lps dot ens.fr
2014-11-30 17:28 ` kargl at gcc dot gnu.org
2014-11-30 17:44 ` dominiq at lps dot ens.fr
2020-07-13 21:27 ` dominiq at lps dot ens.fr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).