public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-106830-4-Ajnsnocoo9@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-106830-4@http.gcc.gnu.org/bugzilla/>

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...

  reply	other threads:[~2022-09-05  9:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-05  5:28 [Bug c/106830] New: " zsojka at seznam dot cz
2022-09-05  9:11 ` jakub at gcc dot gnu.org [this message]
2022-09-05  9:11 ` [Bug c/106830] " jakub at gcc dot gnu.org
2022-09-05 10:12 ` [Bug c/106830] [13 Regression] ICE: in tree_to_uhwi, at tree.cc:6392 (from check_for_xor_used_as_pow) since r13-2386-gbedfca647a9e9c1a marxin at gcc dot gnu.org
2022-09-06  5:06 ` zsojka at seznam dot cz
2022-09-06 15:58 ` dmalcolm at gcc dot gnu.org
2022-09-07  1:24 ` dmalcolm at gcc dot gnu.org
2022-09-22 12:36 ` cvs-commit at gcc dot gnu.org
2022-09-22 12:41 ` dmalcolm at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-106830-4-Ajnsnocoo9@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).