public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/97242] New: Pointer assignment: Noncontiguous target to contiguous pointer wrongly accepted.
@ 2020-09-29 12:12 burnus at gcc dot gnu.org
  2020-09-30  9:52 ` [Bug fortran/97242] " dominiq at lps dot ens.fr
  2020-09-30 13:14 ` burnus at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: burnus at gcc dot gnu.org @ 2020-09-29 12:12 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97242
           Summary: Pointer assignment: Noncontiguous target to contiguous
                    pointer wrongly accepted.
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
  Target Milestone: ---

The lines:
  P => B(i)%A(:,::3,::4)   ! <<<
  P => C(::2,::2,::2)      ! <<<

are wrongly accepted – although the compiler can know that it is invalid →
gfc_is_not_contiguous() should detect this.


--------------
implicit none
type t
  integer, allocatable :: A(:,:,:)
end type t

type(t), target :: B(5)
integer, pointer, contiguous :: P(:,:,:)
integer, target :: C(5,5,5)
integer :: i

i = 1

! OK: contiguous
P => B(i)%A
P => B(i)%A(:,:,:)
P => C
P => C(:,:,:)
call foo (B(i)%A)
call foo (B(i)%A(:,:,:))
call foo (C)
call foo (C(:,:,:))

! Invalid - not contiguous
! "If the pointer object has the CONTIGUOUS attribute, the pointer target shall
be contiguous."
! → known to be noncontigous (not always checkable, however)
P => B(i)%A(:,::3,::4)   ! <<<
P => C(::2,::2,::2)      ! <<<

! This following is stricter:
! C1541  The actual argument corresponding to a dummy pointer with the
!        CONTIGUOUS attribute shall be simply contiguous (9.5.4).
call foo (B(i)%A(:,::3,::4))  ! { dg-error "must be simply contiguous" }
call foo (C(::2,::2,::2))     ! { dg-error "must be simply contiguous" }

contains
  subroutine foo(Q)
    integer, pointer, intent(in), contiguous :: Q(:,:,:)
  end subroutine foo
end

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug fortran/97242] Pointer assignment: Noncontiguous target to contiguous pointer wrongly accepted.
  2020-09-29 12:12 [Bug fortran/97242] New: Pointer assignment: Noncontiguous target to contiguous pointer wrongly accepted burnus at gcc dot gnu.org
@ 2020-09-30  9:52 ` dominiq at lps dot ens.fr
  2020-09-30 13:14 ` burnus at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: dominiq at lps dot ens.fr @ 2020-09-30  9:52 UTC (permalink / raw)
  To: gcc-bugs

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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
   Last reconfirmed|                            |2020-09-30
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug fortran/97242] Pointer assignment: Noncontiguous target to contiguous pointer wrongly accepted.
  2020-09-29 12:12 [Bug fortran/97242] New: Pointer assignment: Noncontiguous target to contiguous pointer wrongly accepted burnus at gcc dot gnu.org
  2020-09-30  9:52 ` [Bug fortran/97242] " dominiq at lps dot ens.fr
@ 2020-09-30 13:14 ` burnus at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: burnus at gcc dot gnu.org @ 2020-09-30 13:14 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
FIXED – but the git-hook script did not add the commit :-(

r11-3556-g65167982efa4dbb96698d026e6d7e17acb513f0a
commit 65167982efa4dbb96698d026e6d7e17acb513f0a
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Wed Sep 30 15:01:13 2020 +0200

    Fortran: add contiguous check for ptr assignment, fix non-contig check
(PR97242)

    gcc/fortran/ChangeLog:

            PR fortran/97242
            * expr.c (gfc_is_not_contiguous): Fix check.
            (gfc_check_pointer_assign): Use it.

    gcc/testsuite/ChangeLog:

            PR fortran/97242
            * gfortran.dg/contiguous_11.f90: New test.
            * gfortran.dg/contiguous_4.f90: Update.
            * gfortran.dg/contiguous_7.f90: Update.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-09-30 13:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-29 12:12 [Bug fortran/97242] New: Pointer assignment: Noncontiguous target to contiguous pointer wrongly accepted burnus at gcc dot gnu.org
2020-09-30  9:52 ` [Bug fortran/97242] " dominiq at lps dot ens.fr
2020-09-30 13:14 ` burnus at gcc dot gnu.org

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