http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47775
Summary: Error on allocatable array returned by function Product: gcc Version: 4.5.3 Status: UNCONFIRMED Severity: major Priority: P3 Component: libfortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: fmarti...@gmv.com Created attachment 23370 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23370 Modules, one program and a data file in XML A function returning an allocatable array seems to have the return array variable already allocated on entry to the function. The attempt to allocate it generates the error: Fortran runtime error: Attempting to allocate already allocated array 'res' In module t_dom_node_slist_ftl.f90 the commented lines 1358 to 1361 solve the problem but would expect that function return allocatable arrays are not allocated on entry (this is the observed behaviour in Intel and g95) The attached .tar.gz contains the collection of files that reproduce the problem (sorry, but I have not been able to isolate the problem in a smaller case). The compilation command line I have used is: > /opt/gfortran/bin/gfortran -g m_string.F90 m_messages.f90 m_util_convert.f90 > m_xml.f90 m_dom_element.f90 t_dom_element_pure_tree_ftl.f90 > t_string_slist_ftl.f90 m_dom_node.f90 t_dom_node_slist_ftl.f90 > m_dom_xpath.f90 m_dom.f90 m_unit_support.f90 unit_m_dom_xpath.f90 The resulting a.out has to be executed with the command line: > ./ a.out 1 this uses the file unit_m_dom.xml as input Cheers, Fran