From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AC21D3857354; Fri, 30 Sep 2022 19:46:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC21D3857354 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664567192; bh=VLDJjK8IiEd1FlgTipxp/cl7YuI0mDTa3QXIqnmjcAs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Mg6k1JkDJxfVEEFPDqdK2TWc3LtntIOUZF31nkwRxbwlfv3VpXqZ9YUqaPFVzL8n9 65l2Pt2E8Wg3+VpUKjGDQ+jh54iIb8CVu0Td40bQMtVPDcTEYdRnXgsGAoq3bAHVth ayQDDB/J1tGKR7bafV3L7gD253M6OvUKJZ3GxS4s= From: "anlauf 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: Fri, 30 Sep 2022 19:46:24 +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: 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: 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 #14 from anlauf at gcc dot gnu.org --- (In reply to Mikael Morin from comment #13) > If we pass this check, we proceed to reduce_binary, where if one (or both) > of the operands is an array, we do numerical evaluation for every element= of > the array. >=20 > With the guarding check above, it is safe, with the assumption that eleme= nts > of an array have the same type as the array itself. If that condition is > not true, well, it doesn't work obviously. >=20 > I don't see right now where an additional check would fit well, but the f= ix > doesn't belong to walk_array_constructor in any case from my point of vie= w. 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. This patch tried to perform checks in reduce_binary_ac, but I was not happy with that particular implementation. When looping over the elements, we currently have gfc_simplify_expr (c->expr, 0); 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); 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?=