public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "anlauf at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/114001] New: is_contiguous considers unlimited polymorphic dummy always as contiguous
Date: Mon, 19 Feb 2024 20:17:13 +0000	[thread overview]
Message-ID: <bug-114001-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 114001
           Summary: is_contiguous considers unlimited polymorphic dummy
                    always as contiguous
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anlauf at gcc dot gnu.org
  Target Milestone: ---

While discussing pr105868 I found the following issue:

program main
  implicit none
  integer :: i
  integer, target  :: m(10) = [(i,i=1,size(m))]
  integer, pointer :: p(:)
  p => m(1::3)
  print *, "main: is_contiguous (p)=", is_contiguous (p)
  print *, p
  print *
  call sub (p)
contains
  subroutine sub (x)
    class(*), intent(in) :: x(:)
    print *, "sub(1): is_contiguous (x)=", is_contiguous (x)  ! <- always true
    select type (x)
    type is (integer)
       print *, "sub(2): is_contiguous (x)=", is_contiguous (x)
       print *, x
    end select
  end
end

This prints (since gcc-9 when is_contiguous was added):

 main: is_contiguous (p)= F
           1           4           7          10

 sub(1): is_contiguous (x)= T
 sub(2): is_contiguous (x)= F
           1           4           7          10

The dump-tree clearly has:

      _gfortran_transfer_character_write (&dt_parm.4, &"sub(1): is_contiguous
(x)="[1]{lb: 1 sz: 1}, 26);
      {
        static logical(kind=4) C.4341 = 1;

        _gfortran_transfer_logical_write (&dt_parm.4, &C.4341, 4);
      }

So we aren't actually testing the argument outside the select type block,
whereas:

              _gfortran_transfer_character_write (&dt_parm.5, &"sub(2):
is_contiguous (x)="[1]{lb: 1 sz: 1}, 26);
              {
                struct array01_integer(kind=4) D.4353;
                logical(kind=4) D.4354;

                D.4353 = __tmp_INTEGER_4;
                D.4354 = D.4353.dim[0].stride == 1;
                _gfortran_transfer_logical_write (&dt_parm.5, &D.4354, 4);
              }

             reply	other threads:[~2024-02-19 20:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-19 20:17 anlauf at gcc dot gnu.org [this message]
2024-02-20 21:10 ` [Bug fortran/114001] " anlauf at gcc dot gnu.org
2024-03-12 22:13 ` anlauf at gcc dot gnu.org
2024-03-13 17:55 ` cvs-commit at gcc dot gnu.org
2024-03-19 19:21 ` cvs-commit at gcc dot gnu.org
2024-03-19 19:24 ` 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-114001-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).