From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16654 invoked by alias); 10 Jan 2013 15:46:32 -0000 Received: (qmail 16579 invoked by uid 48); 10 Jan 2013 15:46:14 -0000 From: "janus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/49213] [OOP] gfortran rejects structure constructor expression Date: Thu, 10 Jan 2013 15:46: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-Keywords: X-Bugzilla-Severity: major X-Bugzilla-Who: janus at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 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: 2013-01/txt/msg00954.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49213 --- Comment #8 from janus at gcc dot gnu.org 2013-01-10 15:46:12 UTC --- (In reply to comment #7) > I want to emphasize again that the error I wanted to report was that gfortran > is rejecting valid structure constructor expressions (see comment 3). Here is a slightly reduced version of comment 3: type :: S integer :: n end type type(S) :: Sobj type :: T class(S), allocatable :: x end type Sobj = S(1) call pass_it (T(Sobj)) contains subroutine pass_it (foo) type(T) :: foo end subroutine end One can get past the error message with the following patch: Index: gcc/fortran/resolve.c =================================================================== --- gcc/fortran/resolve.c (revision 194927) +++ gcc/fortran/resolve.c (working copy) @@ -1103,7 +1103,7 @@ resolve_structure_cons (gfc_expr *expr, int init) /* If we don't have the right type, try to convert it. */ if (!comp->attr.proc_pointer && - !gfc_compare_types (&cons->expr->ts, &comp->ts)) + !gfc_compare_types (&comp->ts, &cons->expr->ts)) { t = FAILURE; if (strcmp (comp->name, "_extends") == 0) but the one runs into an ICE: internal compiler error: in fold_convert_loc, at fold-const.c:1986 call pass_it (T(Sobj)) ^ 0x845634 fold_convert_loc(unsigned int, tree_node*, tree_node*) /home/jweil/gcc48/trunk/gcc/fold-const.c:1986 0x671aa9 gfc_trans_subcomponent_assign /home/jweil/gcc48/trunk/gcc/fortran/trans-expr.c:6001 0x671e10 gfc_trans_structure_assign /home/jweil/gcc48/trunk/gcc/fortran/trans-expr.c:6068 0x671f46 gfc_conv_structure(gfc_se*, gfc_expr*, int) /home/jweil/gcc48/trunk/gcc/fortran/trans-expr.c:6095