From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 97AA23858030; Tue, 1 Feb 2022 20:53:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 97AA23858030 From: "sgk at troutmask dot apl.washington.edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/104332] [9/10/11/12 Regression] ICE in resolve_symbol, at fortran/resolve.cc:15815 Date: Tue, 01 Feb 2022 20:53:14 +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: X-Bugzilla-Severity: normal X-Bugzilla-Who: sgk at troutmask dot apl.washington.edu X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P4 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: 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, 01 Feb 2022 20:53:14 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104332 --- Comment #4 from Steve Kargl -= -- On Tue, Feb 01, 2022 at 08:04:45PM +0000, kargl at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104332 >=20 > kargl at gcc dot gnu.org changed: >=20 > What |Removed |Added > -------------------------------------------------------------------------= --- > Ever confirmed|0 |1 > Status|UNCONFIRMED |NEW > Last reconfirmed| |2022-02-01 >=20 > --- Comment #3 from kargl at gcc dot gnu.org --- > (In reply to G. Steinmetz from comment #0) > > Affects versions down to r8 (ifort/ifx rejects it) : > >=20 > >=20 > > $ cat z1.f90 > > block data > > bind(c) a > > end > >=20 >=20 > This fixes the ICE by avoiding a NULL pointer dereference. >=20 > diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc > index 835a4783718..0ea68c707a0 100644 > --- a/gcc/fortran/resolve.cc > +++ b/gcc/fortran/resolve.cc=20 > @@ -15812,8 +15815,9 @@ resolve_symbol (gfc_symbol *sym) >=20 > /* First, make sure the variable is declared at the > module-level scope (J3/04-007, Section 15.3). */ > - if (sym->ns->proc_name->attr.flavor !=3D FL_MODULE && > - sym->attr.in_common =3D=3D 0) > + if (sym->ns->proc_name > + && sym->ns->proc_name->attr.flavor !=3D FL_MODULE > + && sym->attr.in_common =3D=3D 0) > { > gfc_error ("Variable %qs at %L cannot be BIND(C) because it " > "is neither a COMMON block nor declared at the " OK. So, the above stops the ICE, but allows the code to compile, which is bad. The code is invalid by C819. From C1415, the=20 BIND statement would apply to a common block. Thus, the following is valid code block data common /a/x bind(c) :: /a/ end block data=