public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "xry111 at mengyan1223 dot wang" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/104842] New: mips: signed overflow in LUI_OPERAND
Date: Tue, 08 Mar 2022 16:54:24 +0000	[thread overview]
Message-ID: <bug-104842-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104842

            Bug ID: 104842
           Summary: mips: signed overflow in LUI_OPERAND
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xry111 at mengyan1223 dot wang
  Target Milestone: ---

Found this building GCC on mips64el-linux-gnuabi64 with bootstrap-ubsan
(testing a patch enabling ubsan for mips64*-linux-gnu*):

../../gcc/gcc/config/mips/predicates.md:382:11: runtime error: signed integer
overflow: 9223372036854775807 + 65536 cannot be represented in type 'long    
int'

That line uses LUI_INT (x), which expands to LUI_OPERAND (INTVAL (x)). 
LUI_OPERAND is defined as:

#define LUI_OPERAND(VALUE) \
  (((VALUE) | 0x7fff0000) == 0x7fff0000 \
   || ((VALUE) | 0x7fff0000) + 0x10000 == 0)

Obviously this will cause a signed overflow when INTVAL (x) is, for example,
the maximum value of HOST_WIDE_INT.

             reply	other threads:[~2022-03-08 16:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-08 16:54 xry111 at mengyan1223 dot wang [this message]
2022-03-09  3:21 ` [Bug target/104842] " cvs-commit at gcc dot gnu.org
2022-03-09  3:22 ` xry111 at mengyan1223 dot wang

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-104842-4@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).