From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22035 invoked by alias); 4 Apr 2008 09:19:39 -0000 Received: (qmail 21907 invoked by uid 48); 4 Apr 2008 09:18:53 -0000 Date: Fri, 04 Apr 2008 09:19:00 -0000 Subject: [Bug fortran/35824] New: Overloading problems with derived type with allocatable array X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "everyo at gmx dot net" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2008-04/txt/msg00345.txt.bz2 I have a derived type with an allocatable array and have overloaded some operations. Unfortunately assignments like a=-a don't work. Code in the Module, where I definde the type: type alltype double precision :: a double precision,allocatable :: b(:) end type interface assignment(=) module procedure at_from_at end interface interface operator(-) module procedure neg_at end interface contains subroutine at_from_at(b,a) type(alltype), intent(in) :: a type(alltype), intent(out) :: b b%a=a%a allocate(b%b(2)) b%b=a%b end subroutine at_from_at function neg_at(a) result(b) type(alltype), intent(in) :: a type(alltype) :: b b%a=-a%a allocate(b%b(2)) b%b=-a%b end function neg_at The allocatable array has an dimension of 2 in this example... Now the code: use typemodule type(alltype) t1,t2,t3 allocate(t1%b(2)) t1%a=0.5d0 t1%b(1)=1d0 t1%b(2)=2d0 t2=-t1 write(*,*) t2%a, t2%b t1=-t1 write(*,*) t1%a, t1%b Prints: -0.50000000000000000 -1.00000000000000000 -2.0000000000000000 Segmentation fault It seems that in the Module, the allocatated array of t1 doesn't get passed properly in the t1=-t1 part. I have also seg. faults in situations like a=a+b (where + is overloaded simiarly) The same code works correctly with ifort. -- Summary: Overloading problems with derived type with allocatable array Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: everyo at gmx dot net GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35824