public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit 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: Sat, 04 Mar 2023 09:15:16 +0000	[thread overview]
Message-ID: <bug-107846-4-9meGi6UwrY@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

--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:db1405ddf566fe6129328229579b3f98a574b34c

commit r13-6474-gdb1405ddf566fe6129328229579b3f98a574b34c
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sat Mar 4 10:14:33 2023 +0100

    c-family: Account for integral promotions of left shifts for
-Wshift-overflow warning [PR107846]

    The r13-1100-gacb1e6f43dc2bbedd124 change added match.pd narrowing
    of left shifts, and while I believe the C++ FE calls the warning on
unfolded
    trees, the C FE folds them and so left shifts where integral promotion
    happened and so were done in int type will be usually narrowed back to
    char/signed char/unsigned char/short/unsigned short left shifts if the
    shift count is constant and fits into the precision of the var being
    shifted.
    One possibility would be to restrict the match.pd optimization to GIMPLE
    only, another don't fold in C FE before this warning (well, we need to
    fold the shift count operand to constant if possible), the following patch
    just takes integral promotion into account in the warning code.

    2023-03-04  Jakub Jelinek  <jakub@redhat.com>

            PR c/107846
            * c-warn.cc: Include langhooks.h.
            (maybe_warn_shift_overflow): Set type0 to what TREE_TYPE (op0)
            promotes to rather than TREE_TYPE (op0) itself, if TREE_TYPE (op0)
            is narrower than type0 and unsigned, use wi::min_precision with
            UNSIGNED and fold_convert op0 to type0 before emitting the warning.

            * gcc.dg/pr107846.c: New test.

  parent reply	other threads:[~2023-03-04  9:15 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 ` [Bug c/107846] [13 Regression] " pinskia at gcc dot gnu.org
2022-11-23 19:12 ` 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 [this message]
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-9meGi6UwrY@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).