This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/83416] [8 Regression] Invalid rejection of association of contiguous pointer to a target


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

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

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

--- Comment #3 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
gfortran intentionally rejects such code.

You have

  type t
     integer, pointer, contiguous :: a(:)
  end type t
  integer, pointer :: x(:)

and later

  allocate (x(n))
  z% a => x

x is _not_ declared contiguous, so the code here is trying to do
what we expressively don't want to allow - a pointer assignment
from a non-contiguous pointer to a contiguous pointer, which can
lead to silent wrong-code bugs.  (To find that, in this case,
the allocate statements produces something that will be contiguous,
would require forward propagation of values, something that we don't
do).

The solution is easy: Change

  integer, pointer :: x(:)

to

  integer, pointer, contiguous :: x(:)

and your code will be clean.  If you suddenly find out that
this gets rejected somewhere else, you will have found a bug in
your code :-)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]