From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AD5E93858D32; Mon, 5 Sep 2022 09:11:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AD5E93858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662369064; bh=rSOoPKgHLovd8QrYjMW+hVZHsskBcyOArSvEMLN6uRY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=BXcYoqUGgfq4PL4wv7HSZggxP2kzqucezFmBPZjVsDRgE+KYcDqs7KsoWidNa2/iJ 9+H8KlRorXyyb2i1qBweGvB6fKh/KrwgfgoHDu4pXbzKwy2fuFrakzLladNMwimaM6 oXaiGeB4szhZ8sKKfgeKgfEaW8aU5U8P53+68+lQ= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/106830] [13 Regression] ICE: in tree_to_uhwi, at tree.cc:6392 (from check_for_xor_used_as_pow) Date: Mon, 05 Sep 2022 09:11:04 +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-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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: 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=3D106830 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dmalcolm at gcc dot gnu.or= g, | |jakub at gcc dot gnu.org --- Comment #1 from Jakub Jelinek --- I certainly see a valgrind diagnostics on it: valgrind ./cc1 -quiet pr106830.c =3D=3D2461995=3D=3D Memcheck, a memory error detector =3D=3D2461995=3D=3D Copyright (C) 2002-2022, and GNU GPL'd, by Julian Sewar= d et al. =3D=3D2461995=3D=3D Using Valgrind-3.19.0 and LibVEX; rerun with -h for cop= yright info =3D=3D2461995=3D=3D Command: ./cc1 -quiet pr106830.c =3D=3D2461995=3D=3D=20 pr106830.c:1:1: warning: return type defaults to =E2=80=98int=E2=80=99 [-Wi= mplicit-int] 1 | foo0_u16_0() { | ^~~~~~~~~~ pr106830.c: In function =E2=80=98foo0_u16_0=E2=80=99: pr106830.c:2:14: warning: integer constant is so large that it is unsigned 2 | (__int128)(18302628885633695743 << 4) ^ 0; | ^~~~~~~~~~~~~~~~~~~~ =3D=3D2461995=3D=3D Conditional jump or move depends on uninitialised value= (s) =3D=3D2461995=3D=3D at 0xAFCE3D: parser_build_binary_op(unsigned int, tr= ee_code, c_expr, c_expr) (c-typeck.cc:3992) =3D=3D2461995=3D=3D by 0xB4ABA2: c_parser_binary_expression(c_parser*, c= _expr*, tree_node*) (c-parser.cc:8083) =3D=3D2461995=3D=3D by 0xB486A3: c_parser_conditional_expression(c_parse= r*, c_expr*, tree_node*) (c-parser.cc:7651) =3D=3D2461995=3D=3D by 0xB48308: c_parser_expr_no_commas(c_parser*, c_ex= pr*, tree_node*) (c-parser.cc:7565) so pressumably arg1.m_decimal is uninitialized. I see there various spots at which m_decimal can remain uninitialized, in t= his case e.g. c_parser_cast_expression ret.value =3D c_cast_expr (cast_loc, type_name, expr.value); if (ret.value && expr.value) set_c_expr_source_range (&ret, cast_loc, expr.get_finish ()); ret.original_code =3D ERROR_MARK; ret.original_type =3D NULL; return ret; doesn't set it. I'd search for all assignments to original_code in c/*.cc = and added m_decimal =3D 0 next to it if it doesn't have it yet. Another case is check_for_xor_used_as_pow implementation, if it only works = on UHWIs, then /* Only complain if both args are non-negative integer constants. */ if (!(TREE_CODE (lhs_val) =3D=3D INTEGER_CST && tree_int_cst_sgn (lhs_val) >=3D 0)) return; if (!(TREE_CODE (rhs_val) =3D=3D INTEGER_CST && tree_int_cst_sgn (rhs_val) >=3D 0)) return; should actually be if (!tree_fits_uhwi_p (lhs_val) || !tree_fits_uhwi_p (rhs_val)) return; so that for larger values we return immediately. As for lhs we only care about 2 and 10, it doesn't hurt at least for lhs_va= l. For rhs, you'd need to use wide_ints otherwise but then the question is how= to print that...=