From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7810) id 12B2F3853577; Mon, 13 Jun 2022 10:13:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 12B2F3853577 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Alex Coplan To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/ARM/heads/morello)] cp: Use same_type_p in cp_build_binary_op for intcap check X-Act-Checkin: gcc X-Git-Author: Alex Coplan X-Git-Refname: refs/vendors/ARM/heads/morello X-Git-Oldrev: 7d494d93b8fd36101ca2ab6472ed8e4c88c8d633 X-Git-Newrev: b479d8363d3f0387747de0d039ad9870d3908624 Message-Id: <20220613101356.12B2F3853577@sourceware.org> Date: Mon, 13 Jun 2022 10:13:56 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jun 2022 10:13:56 -0000 https://gcc.gnu.org/g:b479d8363d3f0387747de0d039ad9870d3908624 commit b479d8363d3f0387747de0d039ad9870d3908624 Author: Alex Coplan Date: Sat May 7 18:38:44 2022 +0100 cp: Use same_type_p in cp_build_binary_op for intcap check This fixes an ICE seen with the following testcase (reduced from building purecap libstdc++): typedef long T; T sz; __intcap f() { return sz + (__intcap)f; } the issue here is that we have two different non-capability types: T and long are both really the same type, but are represented by different nodes in the IR, so pointer equality fails us, and we ICE in cp_build_binary_op. Adjust the check to use same_type_p instead. gcc/cp/ChangeLog: * typeck.c (cp_build_binary_op): Use same_type_p to check the non-capability type of the final intcap type is the same type as the type we did the arithmetic in. Diff: --- gcc/cp/typeck.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 84fecd410cf..5bab85e412b 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -5879,7 +5879,7 @@ cp_build_binary_op (const op_location_t &location, { tree ic_type = cp_common_type (TREE_TYPE (intcap), TREE_TYPE (result)); - gcc_assert (TREE_TYPE (result) == noncapability_type (ic_type)); + gcc_assert (same_type_p (TREE_TYPE (result), noncapability_type (ic_type))); intcap = cp_convert (ic_type, intcap, complain); result = fold_build_replace_address_value_loc (location, intcap,