From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BF4CF3858C31; Wed, 22 Nov 2023 14:27:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BF4CF3858C31 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1700663235; bh=SePJLVN5fImJLiudQJpUfzYQP8xGlPw1lLzOgf++Z7Q=; h=From:To:Subject:Date:In-Reply-To:References:From; b=xrjnsi3pmLVglkLjf/uMkeKRxLMvNPAxZNd3AZzjpaR2ByBb7TNmhNLFEl/FccSov i5df2pywbuBlU738b/sX+FLZmDXGnZQY381uAq67VwE2M3GRIUUov3buJiuMDr/IWX 7/4tnPYMfg4rUqGzS8rUelGXfo2XkjTuKnRbpGCE= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/111922] [11/12/13/14 Regression] ICE in cp with -O2 -fno-tree-fre Date: Wed, 22 Nov 2023 14:27:14 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ipa X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub 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: 11.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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=3D111922 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |amacleod at redhat dot com, | |jakub at gcc dot gnu.org --- Comment #4 from Jakub Jelinek --- Slightly cleaned up: void f2 (void); void f4 (int, int, int); struct A { int a; }; struct B { struct A *b; int c; } v; static int f1 (x, y) struct C *x; struct A *y; { (v.c =3D v.b->a) || (v.c =3D v.b->a); f2 (); } static void f3 (int x, int y) { int b =3D f1 (0, ~x); f4 (0, 0, v.c); } void f5 (void) { f3 (0, 0); } The problem is in the f1 call, given it uses the K&R definition style and t= he caller invokes UB by using incompatible types (int vs. pointers), I think IPA-VRP should punt somewhere on the type mismatch. I think Value_Range vr (operand_type); if (TREE_CODE_CLASS (operation) =3D=3D tcc_unary) ipa_vr_operation_and_type_effects (vr, src_lats->m_value_range.m_vr, operation, param_type, operand_type); should be avoided if param_type is not a compatible type to operand_type, unless operation is some cast operation (NOP_EXPR, CONVERT_EXPR, dunno if t= he float to integral or vice versa ops as well but vrp probably doesn't handle that yet). In the above case, param_type is struct A *, i.e. pointer, while operand_ty= pe is int.=