From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1D2E23858D38; Mon, 3 Oct 2022 10:06:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1D2E23858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664791561; bh=YMRgR7HIr2dTC1doasGOw391id2IyhjARq99Yscmvqo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=wqyTO3UcDTDXsVfSNfx/cGPQOiLbzhZIs3rFZ3Dq0DjBjv+Hs+tnnQS72PERzD0W7 2ZAVDw4NMmrIhd87++qVluaZTCI0dW7kXHwvE4N0v3ehvAxovajEMY0/ebYrVVTF/x INX7cu0K1Ai1mUQoaqIu9oHoilEC6fe3FFEPaqw8= From: "mikael at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/107000] ICE in gfc_real2complex, at fortran/arith.cc:2243 Date: Mon, 03 Oct 2022 10:05:59 +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: 13.0 X-Bugzilla-Keywords: ice-on-invalid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: mikael 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: 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=3D107000 --- Comment #18 from Mikael Morin --- (In reply to anlauf from comment #14) >=20 > We could walk through the elements of each array passed to reduce_binary > and check the types of the elements there, or do this check in a somewhat > more clever way than in the patch attached to comment#3. >=20 > This patch tried to perform checks in reduce_binary_ac, but I was not hap= py > with that particular implementation. >=20 > When looping over the elements, we currently have >=20 > gfc_simplify_expr (c->expr, 0); >=20 > if (c->expr->expr_type =3D=3D EXPR_CONSTANT) > rc =3D eval (c->expr, op2, &r); > else > rc =3D reduce_binary_ac (eval, c->expr, op2, &r); >=20 > and do not handle the case that c->expr->ts.type =3D=3D BT_UNKNOWN. > Should we return sth. like rc =3D ARITH_INCOMMENSURATE, except that it is > not array .op. array? Well, a new return code seems better (ARITH_INVALID_TYPE ?). I think it's better to move the check to the various gfc_arith_times, gfc_arith_plus, gfc_arith_concat etc, because only those functions know what type is appropriate and what is not. Admittedly BT_UNKNOWN is probably never appropriate, and the check could be done in reduce_binary_ac, but then it should be in reduce_binary_ca, reduce_binary_aa and reduce_unary as well. Then what's missing is a goto runtime in eval_intrinsic if evaluation retur= ns ARITH_INVALID_TYPE. That's the first solution.=