[Bug c/106830] [13 Regression] ICE: in tree_to_uhwi, at tree.cc:6392 (from check_for_xor_used_as_pow)
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Sep 5 09:11:04 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106830
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dmalcolm at gcc dot gnu.org,
| |jakub at gcc dot gnu.org
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I certainly see a valgrind diagnostics on it:
valgrind ./cc1 -quiet pr106830.c
==2461995== Memcheck, a memory error detector
==2461995== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==2461995== Using Valgrind-3.19.0 and LibVEX; rerun with -h for copyright info
==2461995== Command: ./cc1 -quiet pr106830.c
==2461995==
pr106830.c:1:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
1 | foo0_u16_0() {
| ^~~~~~~~~~
pr106830.c: In function ‘foo0_u16_0’:
pr106830.c:2:14: warning: integer constant is so large that it is unsigned
2 | (__int128)(18302628885633695743 << 4) ^ 0;
| ^~~~~~~~~~~~~~~~~~~~
==2461995== Conditional jump or move depends on uninitialised value(s)
==2461995== at 0xAFCE3D: parser_build_binary_op(unsigned int, tree_code,
c_expr, c_expr) (c-typeck.cc:3992)
==2461995== by 0xB4ABA2: c_parser_binary_expression(c_parser*, c_expr*,
tree_node*) (c-parser.cc:8083)
==2461995== by 0xB486A3: c_parser_conditional_expression(c_parser*, c_expr*,
tree_node*) (c-parser.cc:7651)
==2461995== by 0xB48308: c_parser_expr_no_commas(c_parser*, c_expr*,
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 this
case e.g.
c_parser_cast_expression
ret.value = 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 = ERROR_MARK;
ret.original_type = NULL;
return ret;
doesn't set it. I'd search for all assignments to original_code in c/*.cc and
added m_decimal = 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) == INTEGER_CST
&& tree_int_cst_sgn (lhs_val) >= 0))
return;
if (!(TREE_CODE (rhs_val) == INTEGER_CST
&& tree_int_cst_sgn (rhs_val) >= 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_val.
For rhs, you'd need to use wide_ints otherwise but then the question is how to
print that...
More information about the Gcc-bugs
mailing list