http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56008
Bug #: 56008 Summary: [F03] lhs-allocation invoking the array-constructor on DDTs causes memory error Classification: Unclassified Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: stefan.mauerber...@gmail.com Created attachment 29183 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29183 minimal testcase Hi There! I encountered some wired behavior with F03's automatic (re)allocation features in 4.7.2 and 4.8.0 from trunk. What I have is a DDT with an allocatable member-variable. > TYPE :: test_typ > REAL, ALLOCATABLE :: a(:) > END TYPE I am initializing two instances of that type 'xx' and 'yy' with allocated member-variables. In addition there is an allocatable array 'conc' of 'test_typ' which is not yet allocated. > TYPE(test_typ) :: xx, yy > TYPE(test_typ), ALLOCATABLE :: conc(:) > xx = test_typ( [1.0] ) > yy = test_typ( [1.0,2.0,3.0] ) To allocate 'conc' I want to utilize the array-constructor: > conc = [ xx, yy ] This however, referring to Valgrinds memory analysis, causes a memory error: ==14558== Conditional jump or move depends on uninitialised value(s) ==14558== at 0x401030: MAIN__ (test.f90:16) ==14558== by 0x40118B: main (test.f90:20) ==14558== Uninitialised value was created by a heap allocation ==14558== at 0x4C2B3F8: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==14558== by 0x400DCB: MAIN__ (test.f90:16) ==14558== by 0x40118B: main (test.f90:20) Well, 'gfortran -v -Wall -Wextra test.f90' compiles just fine without any complaints. Also the executable produces results as expected (in most cases). The above problem, however, will be exposed and triggered by initializing the MPI execution environment. Just invoking CALL MPI_INIT() will cause a segmentation fault. First of all I wanted to blame OMPI for that (see: http://www.open-mpi.org/community/lists/users/2013/01/21103.php). However, those guys convinced me asking you for advice. To reproduce all that, there is a minimal test-case attached. In addition, there is a file containing the system configuration and one with Valgrind's memory analysis. Cheers, Stefan (Btw. what is the appropriate Fortran expression/terminology for DDT member-variables)