public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "saitofuyuki at jamstec dot go.jp" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libfortran/108937] New: Intrinsic IBITS(I,POS,LEN) fails when LEN equals to BIT_SIZE(I).
Date: Mon, 27 Feb 2023 01:43:08 +0000	[thread overview]
Message-ID: <bug-108937-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 108937
           Summary: Intrinsic IBITS(I,POS,LEN) fails when LEN equals to
                    BIT_SIZE(I).
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: saitofuyuki at jamstec dot go.jp
  Target Milestone: ---

Created attachment 54539
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54539&action=edit
A minimum patch to fix ibits().

gfc_conv_intrinsic_ishft(), e.g, in gcc/fortran/trans-intrinsic.cc
catches a special case when shift widths GE BIT_SIZE at LSHIFT_EXPR
operation, which is not performed in gfc_conv_intrinsic_ibits.

I attached a minimum patch, and also a test program.

The output of the program before/after patch are as follow:

------------------------ before patch
IBITS(-1,0,32)
intrinsic 0 00000000000000000000000000000000
expected -1 11111111111111111111111111111111

------------------------ after patch
IBITS(-1,0,32)
intrinsic -1 11111111111111111111111111111111
expected -1 11111111111111111111111111111111

As far as I checked, this is a long-standing bug.  At least gfortran
10.4.0, 11.3.0, 12.2.0, and the latest one
(4341106354c6a463ce3628a4ef9c1a1d37193b59).

             reply	other threads:[~2023-02-27  1:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-27  1:43 saitofuyuki at jamstec dot go.jp [this message]
2023-02-27  1:44 ` [Bug libfortran/108937] " saitofuyuki at jamstec dot go.jp
2023-02-27  2:26 ` kargl at gcc dot gnu.org
2023-02-27  3:01 ` saitofuyuki at jamstec dot go.jp
2023-02-27 18:14 ` kargl at gcc dot gnu.org
2023-02-27 19:32 ` anlauf at gcc dot gnu.org
2023-02-27 20:21 ` [Bug fortran/108937] " anlauf at gcc dot gnu.org
2023-02-27 20:55 ` anlauf at gcc dot gnu.org
2023-02-27 21:30 ` cvs-commit at gcc dot gnu.org
2023-02-27 23:07 ` saitofuyuki at jamstec dot go.jp
2023-03-04 19:51 ` cvs-commit at gcc dot gnu.org
2023-03-05 19:35 ` cvs-commit at gcc dot gnu.org
2023-03-05 19:36 ` cvs-commit at gcc dot gnu.org
2023-03-05 19:40 ` anlauf 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-108937-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).