This is the mail archive of the gcc-patches@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]

Re: [patch, fortran] Warn about suspicious assignment to contiguous pointers


Hi Janus,

and in that
case I would argue that, beyond being "not useful", it's even illegal,
so why not throw a hard error, if we can infer at compile-time that
the target is non-contiguous?

Problem is, we cannot infer this from the tests done.
We would also have to add a test if the array is empty
or that it contains only a single element, and that (I think)
is a) impossible in the general case, and b) not worth the bother.

I'm not sure I understand which cases you're worried about here. Maybe
you can give an example?

   real, dimension(5,5), target :: a
   real, dimension(:,:), pointer, contiguous :: ap
   ap => a(4::2,4::2)

points to a single element, which is (by definition) contiguous.

yes, I see that your current patch mishandles this case.

It does _not_ mishandle that case.  It issues a warning for a
very dubious practice. The warning can be turned off at will.

Issuing a hard error whould be mishandling this case.


But why
should it be impossible to detect that there is only a single element?
If the triplet and the array bounds are constant, it is certainly
possible.

Too much work into supporting a corner case of a dubious practice.  I'm
not going to do it.

There are also a few other checks that I missed, for
example

   subroutine foo(a)
   real, dimension(:), target, intent(inout) :: a
   real, dimension(:), contiguous :: ap
   ap => a

I will also address this in a future version of the patch.

How do you want to do that?

Warn in all cases.

Because the code writer can not how if the array passed to the
subroutine is contigous (use case of a library), it is not
possible for him to know if the user will do this correctly or
not.  The correct way to write this subroutine then is

subroutine foo(a)
  real, dimension(:), target, intent(inout), contiguous :: a
  real, dimension(:), contiguous :: ap
  ap => a

when gfortran will someday complain if the dummy argument
is associated with a non-contiguous entity.


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