From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A00703857350; Tue, 19 Apr 2022 16:12:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A00703857350 From: "mikael at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/103662] [12 Regression] TBAA problem in Fortran FE triggering in gfortran.dg/unlimited_polymorphic_3.f03 Date: Tue, 19 Apr 2022 16:12:44 +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: 12.0 X-Bugzilla-Keywords: alias, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: mikael at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Apr 2022 16:12:44 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103662 --- Comment #17 from Mikael Morin --- (In reply to Jakub Jelinek from comment #15) > Now, the question is what is the Fortran unlimited polymorphic semantics,= if > one can store through one type and read through a different type which ju= st > has the same layout, or if it also has to use the same name etc., or if it > is even acceptable to store through say a type with a pair of integers and > read through a type with double precision etc. I think the pointer assignments in foo are invalid: 10.2.2.3 Data pointer assignment =E2=80=A6 If the pointer object is of a type with the BIND attribute or the= SEQUENCE attribute, the dynamic type of the pointer target shall be that type. =3D> the dynamic type of tgt shall be respectively s and t 7.3.2.3 CLASS type specifier =E2=80=A6 The dynamic type of an associated polymorphic pointer is the dyna= mic type of its target. =3D> the dynamic type of tgt is that of z =3D> the dynamic type of z is that of y =3D> the dynamic type of y is that of x, which is sq 7.5.2.4 Determination of derived types =E2=80=A6 Data entities also have the same type if they are declared with r= eference to different derived-type definitions that specify the same type name, all have the SEQUENCE attribute or all have the BIND attribute, have no components w= ith PRIVATE accessibility, and have components that agree in order, name, and attributes. Otherwise, they are of different derived types. =3D> sq and s are different types (different component name) =3D> sq and t are different types (different component name, bind(c), sequ= ence) =3D> s and t are different types (bind(c), sequence) So ptr1 and ptr2 should either have type sq, or s and t should be changed t= o be "compatible" with sq. And "compatible" is defined in the 7.5.2.4 excerpt ab= ove.=