From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5EC2E385B501; Fri, 24 Feb 2023 17:36:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5EC2E385B501 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677260169; bh=5Ww4WwNxqIGmPU4m5prx1ahkNJt46xEi/hUafu5YbbM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=f8eTDv9+IeNBjleVrRhObIhncdti3HvfJW/pOCKiUAeenEDXJthe2dGpJHPYRJUtj fvZPpxmTY50L8vJhMZMYn6VyPBzoGe8h1rpdbOqvM2VVT4gG/yYsuFkwrTOW2D3Oyl FoCq7WhjYepsMEcbFPBnNKCkhwCyRQK802gdWbu8= From: "kargl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/108921] ICE: using the result of an impure function in automatic character allocation Date: Fri, 24 Feb 2023 17:36:08 +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.2.0 X-Bugzilla-Keywords: ice-on-invalid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: kargl at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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: priority keywords 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=3D108921 kargl at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P3 |P4 Keywords| |ice-on-invalid-code CC| |kargl at gcc dot gnu.org --- Comment #1 from kargl at gcc dot gnu.org --- The ever popular NULL pointer dereference from parsing invalid code. With this patch diff --git a/gcc/fortran/class.cc b/gcc/fortran/class.cc index ae653e74437..9ece4482f76 100644 --- a/gcc/fortran/class.cc +++ b/gcc/fortran/class.cc @@ -2491,7 +2491,7 @@ gfc_find_derived_vtab (gfc_symbol *derived) /* This is elemental so that arrays are automatically treated correctly by the scalarizer. */ copy->attr.elemental =3D 1; - if (ns->proc_name->attr.flavor =3D=3D FL_MODULE) + if (ns->proc_name && ns->proc_name->attr.flavor =3D=3D FL= _MODULE) copy->module =3D ns->proc_name->name; gfc_set_sym_referenced (copy); /* Set up formal arguments. */ diff --git a/gcc/fortran/symbol.cc b/gcc/fortran/symbol.cc index 2ce0f3e4df7..54c9441d7fd 100644 --- a/gcc/fortran/symbol.cc +++ b/gcc/fortran/symbol.cc @@ -2499,7 +2499,7 @@ gfc_find_component (gfc_symbol *sym, const char *name, if (sym->attr.flavor =3D=3D FL_DERIVED) sym =3D gfc_use_derived (sym); else - gcc_assert (gfc_fl_struct (sym->attr.flavor)); + return NULL; if (sym =3D=3D NULL) return NULL; I get=20 % gfcx -c a.f90 a.f90:13:34: 13 | character(len=3Dthis%f())::r ! problem appears here | 1 Error: Symbol 'r' at (1) already has basic type of REAL a.f90:13:22: 13 | character(len=3Dthis%f())::r ! problem appears here | 1 Error: Function 'this' at (1) must be PURE a.f90:14:10: 14 | r=3D'42' | 1 Error: Cannot convert CHARACTER(2) to REAL(4) at (1) a.f90:19:9: 19 | use lib | 1 Fatal Error: Cannot open module file 'lib.mod' for reading at (1): No such = file or directory compilation terminated. The first and last errors appear to be run on errors. The second error app= ears to be the relevant one, but the 'name' of the function is munged. Anywhoo, the patch fixes the ICE=