public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Andrew Macleod <amacleod@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-2786] Fix calc_op1 for undefined op2_range. Date: Thu, 22 Sep 2022 18:49:12 +0000 (GMT) [thread overview] Message-ID: <20220922184912.6429138582AE@sourceware.org> (raw) https://gcc.gnu.org/g:a7a6649f4e7c459a95dee1600554ad06aaeb1cf6 commit r13-2786-ga7a6649f4e7c459a95dee1600554ad06aaeb1cf6 Author: Andrew MacLeod <amacleod@redhat.com> Date: Thu Sep 22 10:27:17 2022 -0400 Fix calc_op1 for undefined op2_range. Unary operations pass the type of operand 1 into op1_range. If that range is undefined, the routine blindly picks the type of operand 2, which in the case of a unary op, does not exist and traps. * gimple-range-op.cc (gimple_range_op_handler::calc_op1): Use operand 1 for second range if there is no operand 2. Diff: --- gcc/gimple-range-op.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc index f03125a0fc5..ab5b389449d 100644 --- a/gcc/gimple-range-op.cc +++ b/gcc/gimple-range-op.cc @@ -208,10 +208,14 @@ gimple_range_op_handler::calc_op1 (vrange &r, const vrange &lhs_range, // If op2 is undefined, solve as if it is varying. if (op2_range.undefined_p ()) { - // This is sometimes invoked on single operand stmts. if (gimple_num_ops (m_stmt) < 3) return false; - tree op2_type = TREE_TYPE (operand2 ()); + tree op2_type; + // This is sometimes invoked on single operand stmts. + if (operand2 ()) + op2_type = TREE_TYPE (operand2 ()); + else + op2_type = TREE_TYPE (operand1 ()); Value_Range trange (op2_type); trange.set_varying (op2_type); return op1_range (r, type, lhs_range, trange);
reply other threads:[~2022-09-22 18:49 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220922184912.6429138582AE@sourceware.org \ --to=amacleod@gcc.gnu.org \ --cc=gcc-cvs@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: linkBe 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).