public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/105687] New: non-contiguous data in assumed rank
@ 2022-05-22  8:00 martin.diehl at kuleuven dot be
  0 siblings, 0 replies; only message in thread
From: martin.diehl at kuleuven dot be @ 2022-05-22  8:00 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105687
           Summary: non-contiguous data in assumed rank
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: martin.diehl at kuleuven dot be
  Target Milestone: ---

Created attachment 53014
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53014&action=edit
small reproducer

When passing a strided array to a select-rank statement, the information that
that data is non-contiguous is somehow lost. At least when further passing the
data to an assumed-size function, the arriving data differs.

Note: This might be related to bug 105674. This report illustrates the actual
problem I've encountered (wrong data) while the other report shows intermediate
results when trying to write a minimal reproducer.


code
====
program test

  integer, dimension(2,2), target :: dim_2
  integer, dimension(:,:), pointer :: strided
  integer :: i

  dim_2 = reshape([(i,i=1,size(dim_2))],shape(dim_2))
  strided => dim_2(1:1,:)

  print*, 'is_contiguous(strided)', is_contiguous(strided)
  print*, 'is_contiguous((strided))', is_contiguous((strided))
  print*, ''

  print*, 'call show(strided)'
  call show(strided,size(strided))
  print*, 'call show((strided))'
  call show((strided),size((strided)))
  print*, 'call assumed_rank(strided)'
  call assumed_rank(strided)
  print*, 'call assumed_rank((strided))'
  call assumed_rank((strided))

  contains

  subroutine assumed_rank(dataset)

    integer, intent(in), dimension(..) :: dataset

    select rank(dataset)
      rank(2)
        print*, 'is contiguous in select', is_contiguous(dataset)
        print*, 'data in select', dataset
        call show(dataset,size(dataset))
    end select

    print*, ''

  end subroutine assumed_rank

  subroutine show(dataset,s)

    integer, intent(in) :: s
    integer, intent(in), dimension(*) :: dataset

    print*, 'is contiguous in show', is_contiguous(dataset)
    print*, 'data in show', dataset(1:s)
    print*, ''

  end subroutine show

end program test

output
======
 is_contiguous(strided) F
 is_contiguous((strided)) T

 call show(strided)
 is contiguous in show T
 data in show           1           3

 call show((strided))
 is contiguous in show T
 data in show           1           3

 call assumed_rank(strided)
 is contiguous in select T
 data in select           1           3
 is contiguous in show T
 data in show           1           2


 call assumed_rank((strided))
 is contiguous in select T
 data in select           1           3
 is contiguous in show T
 data in show           1           3

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-22  8:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-22  8:00 [Bug fortran/105687] New: non-contiguous data in assumed rank martin.diehl at kuleuven dot be

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).