This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/83416] [8 Regression] Invalid rejection of association of contiguous pointer to a target
- From: "tkoenig at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 13 Dec 2017 22:25:59 +0000
- Subject: [Bug fortran/83416] [8 Regression] Invalid rejection of association of contiguous pointer to a target
- Auto-submitted: auto-generated
- References: <bug-83416-4@http.gcc.gnu.org/bugzilla/>
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 :-)