From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0744E3858D1E; Mon, 27 Feb 2023 01:43:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0744E3858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677462189; bh=GUu5SPCjpEFZ9Yanl+QdBK6NnuccRdv+cwNr6JN/YOc=; h=From:To:Subject:Date:From; b=mQQOdLg6sNwaa61WmTJf6xJlAhJPOsZPIQxQ/oXhu3LhcOshdNOgajhwi+xOnKA0d KMe745ldU9sEAYf8yV+YeIK7X0aToRIJMw5n0PyH6W20PZtI42gsRqHKDSCViY2s0I 3bZYUrhZpr4Y9iCd4sFCnnh54ZJ2iJlPrdloJ1TQ= From: "saitofuyuki at jamstec dot go.jp" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libfortran X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: saitofuyuki at jamstec dot go.jp X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108937 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=3D54539&action=3Dedit 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).=