public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/56008] New: [F03] lhs-allocation invoking the array-constructor on DDTs causes memory error
@ 2013-01-16 19:37 stefan.mauerberger at gmail dot com
  2013-01-16 19:38 ` [Bug fortran/56008] " stefan.mauerberger at gmail dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: stefan.mauerberger at gmail dot com @ 2013-01-16 19:37 UTC (permalink / raw)
  To: gcc-bugs


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: unassigned@gcc.gnu.org
        ReportedBy: stefan.mauerberger@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)


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

end of thread, other threads:[~2013-02-10 18:35 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-16 19:37 [Bug fortran/56008] New: [F03] lhs-allocation invoking the array-constructor on DDTs causes memory error stefan.mauerberger at gmail dot com
2013-01-16 19:38 ` [Bug fortran/56008] " stefan.mauerberger at gmail dot com
2013-01-16 19:39 ` stefan.mauerberger at gmail dot com
2013-01-16 22:51 ` [Bug fortran/56008] [F03] wrong code with lhs-realloc on assignment with derived types having allocatable components burnus at gcc dot gnu.org
2013-01-19 15:55 ` pault at gcc dot gnu.org
2013-01-20 13:35 ` dominiq at lps dot ens.fr
2013-01-21 19:30 ` pault at gcc dot gnu.org
2013-01-22 19:08 ` stefan.mauerberger at gmail dot com
2013-02-04 22:33 ` pault at gcc dot gnu.org
2013-02-04 22:36 ` pault at gcc dot gnu.org
2013-02-10 18:35 ` stefan.mauerberger at gmail dot com

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