From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 379103829BE2; Thu, 27 Oct 2022 08:27:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 379103829BE2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666859264; bh=Dj8Vxrf/eashoOjvRZ4UCMZv6Ual1ufGYlkCEmBD8LU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=siGWnHkcI7sqMx5EQeBnEJXNc3jU5AssYtPDCfrB3UhPUu9+rPWfv8rGp2rW+8V4C P1/cy4IDbpTkFPS6O07zu9kdR8tAfcMVyotIFB+HTWFymC4Wp/eGoQBTfoFbQtmNkW bk3ocBeCUG2NV1zK2+f5c2uGWXss9OZHwMSjCnVg= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107383] [13 Regression] ICE in cp_build_binary_op, at cp/typeck.cc:6181 Date: Thu, 27 Oct 2022 08:27:32 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: ice-on-invalid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.0 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=3D107383 --- Comment #4 from CVS Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:bfb7994a9fb0b10767d12b8d670c081014ad8b01 commit r13-3522-gbfb7994a9fb0b10767d12b8d670c081014ad8b01 Author: Jakub Jelinek Date: Thu Oct 27 10:24:45 2022 +0200 c++: Fix excess precision related ICE on invalid binop [PR107382, PR107= 383] The following tests ICE in the gcc_assert (common); in cp_build_binary_= op. I've missed that while for * common is set always, while for +, - and / it is in some cases not. If it is not, then if (!result_type && arithmetic_types_p && (shorten || common || short_compare)) condition is false, then the following if (may_need_excess_precision && (orig_type0 !=3D type0 || orig_type1 !=3D type1) && build_type =3D=3D NULL_TREE) would fail the assertion there and if there wouldn't be excess precisio= n, if (code =3D=3D SPACESHIP_EXPR) would be false (for SPACESHIP_EXPR we always have build_type set like f= or other comparisons) and then trigger if (!result_type) { if (complain & tf_error) { binary_op_rich_location richloc (location, orig_op0, orig_op1, true); error_at (&richloc, "invalid operands of types %qT and %qT to binary %q= O", TREE_TYPE (orig_op0), TREE_TYPE (orig_op1), code); } return error_mark_node; } So, if result_type is NULL, we don't really need to compute semantic_result_type because nothing will use it anyway and can get fall through into the error/return error_mark_node; case. 2022-10-27 Jakub Jelinek PR c++/107382 PR c++/107383 * typeck.cc (cp_build_binary_op): Don't compute semantic_result_type if result_type is NULL. * g++.dg/diagnostic/bad-binary-ops2.C: New test.=