public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/107846] [13 Regression] error: result of '8000 << 8' requires 22 bits to represent, but 'short int' only has 16 bits
Date: Wed, 23 Nov 2022 19:09:08 +0000	[thread overview]
Message-ID: <bug-107846-4-3pqqipdVM1@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107846-4@http.gcc.gnu.org/bugzilla/>

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic, needs-bisection
   Last reconfirmed|                            |2022-11-23
             Status|UNCONFIRMED                 |NEW
      Known to work|                            |11.1.0, 12.1.0, 12.2.0,
                   |                            |9.1.0
          Component|target                      |c
   Target Milestone|---                         |13.0
     Ever confirmed|0                           |1
            Summary|error: result of '8000 <<   |[13 Regression] error:
                   |8' requires 22 bits to      |result of '8000 << 8'
                   |represent, but 'short int'  |requires 22 bits to
                   |only has 16 bits            |represent, but 'short int'
                   |                            |only has 16 bits
             Target|bpf                         |

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Short testcase:

typedef unsigned short __u16;

#define ___bpf_mvb(x, b, n, m) ((__u##b)(x) << (b-(n+1)*8) >> (b-8) << (m*8))

#define ___bpf_swab16(x) ((__u16)(                      \
                          ___bpf_mvb(x, 16, 0, 1) |     \
                          ___bpf_mvb(x, 16, 1, 0)))

# define __bpf_constant_htons(x)        ___bpf_swab16(x)

static const int cfg_port = 8000;


unsigned short f(int t)
{
  if (t != __bpf_constant_htons (cfg_port))
    return 1;
  return 0;
}
--- CUT ---
This is definitely a bug in GCC though there might be a dup.
the line info is also missing ...
Note this only happens at -O1 and also a regression from GCC 12 even.

  parent reply	other threads:[~2022-11-23 19:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-23 17:45 [Bug target/107846] New: " james.hilliard1 at gmail dot com
2022-11-23 18:26 ` [Bug target/107846] " david.faust at oracle dot com
2022-11-23 19:02 ` pinskia at gcc dot gnu.org
2022-11-23 19:09 ` pinskia at gcc dot gnu.org [this message]
2022-11-23 19:12 ` [Bug c/107846] [13 Regression] " pinskia at gcc dot gnu.org
2022-11-23 19:20 ` jakub at gcc dot gnu.org
2022-11-29 15:26 ` jakub at gcc dot gnu.org
2022-11-29 18:57 ` james.hilliard1 at gmail dot com
2022-11-29 18:59 ` jakub at gcc dot gnu.org
2022-11-29 19:00 ` pinskia at gcc dot gnu.org
2022-11-29 19:06 ` james.hilliard1 at gmail dot com
2023-03-04  9:15 ` cvs-commit at gcc dot gnu.org
2023-03-04  9:24 ` jakub 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-107846-4-3pqqipdVM1@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).