From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4C065384F025; Thu, 12 Aug 2021 23:33:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4C065384F025 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/101030] [9/10/11/12 Regression] ICE with -Wconversion and a?:b extension in template argument Date: Thu, 12 Aug 2021 23:33:42 +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: 11.1.0 X-Bugzilla-Keywords: diagnostic, ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia 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: 9.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: short_desc 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 23:33:42 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101030 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|[9/10/11/12 Regression] gcc |[9/10/11/12 Regression] ICE |internal error with |with -Wconversion and a?:b |Wconversion |extension in template | |argument --- Comment #2 from Andrew Pinski --- Simple fix but I doubt it is the correct fix: diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c index 84ad6633c96..ddaf0036abc 100644 --- a/gcc/c-family/c-warn.c +++ b/gcc/c-family/c-warn.c @@ -1296,8 +1296,10 @@ conversion_warning (location_t loc, tree type, tree expr, tree result) case COND_EXPR: { /* In case of COND_EXPR, we do not care about the type of - COND_EXPR, only about the conversion of each operand. */ - tree op1 =3D TREE_OPERAND (expr, 1); + COND_EXPR, only about the conversion of each operand + except if we had a?:b then we care about the original + expression. */ + tree op1 =3D TREE_OPERAND (expr, 1) ? TREE_OPERAND (expr, 1) : TREE_OPERAND (expr, 0); tree op2 =3D TREE_OPERAND (expr, 2); return (conversion_warning (loc, type, op1, result)=