From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16582 invoked by alias); 23 Dec 2014 22:44:13 -0000 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 Received: (qmail 16545 invoked by uid 48); 23 Dec 2014 22:44:08 -0000 From: "patnel97269-gfortran at yahoo dot fr" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/64397] [OOP] Runtime segfault with parenthesis expression passed to polymorphic dummy argument Date: Tue, 23 Dec 2014 22:44:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 4.9.2 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: patnel97269-gfortran at yahoo dot fr X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-12/txt/msg02685.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64397 --- Comment #5 from patnel97269-gfortran at yahoo dot fr --- (In reply to janus from comment #3) > Actually one can reduce it even further: > > > program main > > type :: my_integer > real, allocatable :: x(:) > end type > type(my_integer) :: a > > a=my_integer([1]) > write (*,*) "A" > call ass(a) > write (*,*) "B" > call ass((a)) > write (*,*) "C" > > contains > > subroutine ass(b) > class(my_integer), intent(in) :: b > print *,'called ass' > end subroutine > > end > > > This program does not do anything useful any more, but it still shows the > same segfault at/after the call to "ass((a))": > > $ ./a.out > A > called ass > B > called ass > > Program received signal SIGSEGV: Segmentation fault - invalid memory > reference. > > > Making 'b' a TYPE instead of a CLASS makes the error go away. I agree that this example still trigger a bug, but I remember in my original (more complicated) code, the segfault appears when it tries to access the allocatable components of the type in the subroutine before computation and before returning. So the problem might be at entrance and not necessarily after the call. This need to be confirmed.