From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6654 invoked by alias); 29 Dec 2014 16:42:08 -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 6626 invoked by uid 48); 29 Dec 2014 16:42:04 -0000 From: "janus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/60357] [F08] structure constructor with unspecified values for allocatable components Date: Mon, 29 Dec 2014 16:42: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.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: janus at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: janus 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/msg02879.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60357 --- Comment #10 from janus at gcc dot gnu.org --- (In reply to Andre Vehreschild from comment #9) > I just need to > figure, if allocating the component explicitly is valid in Fortran. For sure. I think both the examples in comment 4 and 5 are actually valid Fortran code. In order to make sure we're talking about the same thing, let's have a look at the following code: Type A integer :: X = 1 integer, allocatable :: y end type Type(A) :: Me allocate(Me%y) print *,"A" Me = A(X=1, y=2) print *,"B" print *, Me%y end This is a variant of the example above that produced the segfault. I inserted some print statements in order to debug it. It prints at runtime: A B Program received signal SIGSEGV: Segmentation fault - invalid memory reference. This shows clearly that the segfault occurs when we try to access Me%y in the last print statement, meaning that it is probably unallocated although it clearly should be. -fdump-tree-original shows that the problem is in the translation of the structure constructor assignment, which apparently leaves the y-component unallocated.