From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BFDAF3858C66; Mon, 6 Mar 2023 21:43:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BFDAF3858C66 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678138991; bh=8fvWrR9UxKu8bDCCPgqzhGhb+kJDIf2LO28PlJCeMbg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=s+G7RUjPocA9gVfJ+WlCOxPiKp/WFq5H86w/h+g49WuqviANx2Rucg8a+07wMnstS lRQusO6Fy6IMYpTwpO9kqeE/2nlW3Y5XlgUcy6ID3C7PZhkabmW4Eem9KezEKz9rRV 5mrYc5c58p8HgwLfOjHPGj9IQETFsVceRuD03mKo= From: "anlauf at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/58331] [OOP] Bogus rank checking with explicit-/assumed-size arrays and CLASS Date: Mon, 06 Mar 2023 21:43:10 +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, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: anlauf at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: 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: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D58331 anlauf at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |anlauf at gcc dot gnu.org --- Comment #4 from anlauf at gcc dot gnu.org --- (In reply to Tobias Burnus from comment #2) > Updated patch: > --- a/gcc/fortran/interface.c > +++ b/gcc/fortran/interface.c > @@ -2135 +2135,5 @@ compare_parameter (gfc_symbol *formal, gfc_expr *actu= al, > - || (actual->rank !=3D 0 && !(is_elemental || formal->attr.dimensio= n)) > + || (actual->rank !=3D 0 > + && !(is_elemental > + || (formal->ts.type !=3D BT_CLASS && formal->attr.dimension) > + || (formal->ts.type =3D=3D BT_CLASS > + && CLASS_DATA (formal)->attr.dimension))) > @@ -2142 +2146,4 @@ compare_parameter (gfc_symbol *formal, gfc_expr *actu= al, > - || (actual->rank =3D=3D 0 && formal->attr.dimension > + || (actual->rank =3D=3D 0 > + && (formal->attr.dimension > + || (formal->ts.type =3D=3D BT_CLASS > + && CLASS_DATA (formal)->attr.dimension)) > @@ -2150 +2157,4 @@ compare_parameter (gfc_symbol *formal, gfc_expr *actu= al, > - else if (actual->rank !=3D 0 && (is_elemental || formal->attr.dimensio= n)) > + else if (actual->rank !=3D 0 > + && (is_elemental || formal->attr.dimension > + || (formal->ts.type =3D=3D BT_CLASS > + && CLASS_DATA (formal)->attr.dimension))) When adapting this patch to mainline it seems to work now and regtests ok. Printing array a in mysub gives the right results, and also the tree dump for the call with rank-2 argument looks slightly different: parm.12.data =3D (void *) &b[0]; parm.12.offset =3D -3; class.11._data =3D VIEW_CONVERT_EXPR(parm.12); class.11._len =3D 0; mysub (&class.11, &C.4379); So shall we proceed?=