public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/42112]  New: overloaded function with allocatable result problem
@ 2009-11-19 22:20 mrestelli at gmail dot com
  2009-11-19 23:56 ` [Bug fortran/42112] " kargl at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: mrestelli at gmail dot com @ 2009-11-19 22:20 UTC (permalink / raw)
  To: gcc-bugs

The attached code produces an error at runtime, however it seems fine
to me. Notice that there is no error accessing the function with the
specific name "g", while there is an error when using the generic name
"gen_g".

gfortran --version
GNU Fortran (GCC) 4.5.0 20091105 (experimental)

gfortran ./abc.f90 -o abc

./abc 
At line 23 of file ./abc.f90
Fortran runtime error: Attempting to allocate already allocated array 'j'


module mod_m
 implicit none
 public :: f
 private

 interface gen_g
   module procedure g
 end interface

contains

 pure function f() result(i)
  integer :: i
  integer, allocatable :: loc_ar(:)
   allocate(loc_ar(1))
   loc_ar = gen_g() ! does not work
   !loc_ar = g() ! no problem here
   deallocate(loc_ar)
 end function f

 pure function g() result(j)
  integer, allocatable :: j(:)
   allocate( j(1) )
   j = 2
 end function g

end module mod_m

!--------------------------

program abc_main

 use mod_m, only: f
 implicit none
 integer :: p
  p = f()

end program abc_main


-- 
           Summary: overloaded function with allocatable result problem
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mrestelli at gmail dot com
  GCC host triplet: Linux 2.6.27-gentoo-r8 x86_64 AMD Turion(tm)
GCC target triplet: GNU Fortran (GCC) 4.5.0 20091105 (experimental)


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42112


^ permalink raw reply	[flat|nested] 11+ messages in thread
[parent not found: <bug-42112-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2015-08-07 20:46 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-19 22:20 [Bug fortran/42112] New: overloaded function with allocatable result problem mrestelli at gmail dot com
2009-11-19 23:56 ` [Bug fortran/42112] " kargl at gcc dot gnu dot org
2009-11-20  0:20 ` sgk at troutmask dot apl dot washington dot edu
2009-11-20 14:23 ` burnus at gcc dot gnu dot org
     [not found] <bug-42112-4@http.gcc.gnu.org/bugzilla/>
2010-11-21 12:19 ` pault at gcc dot gnu.org
2010-11-25  8:02 ` pault at gcc dot gnu.org
2010-11-25  8:54 ` burnus at gcc dot gnu.org
2010-11-25  8:59 ` burnus at gcc dot gnu.org
2010-11-28 12:46 ` pault at gcc dot gnu.org
2015-04-17 17:49 ` dominiq at lps dot ens.fr
2015-08-07 20:46 ` mikael at gcc dot gnu.org

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).