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/15809] ICE Using Pointer Functions



------- Comment #14 from pault at gcc dot gnu dot org  2005-11-21 15:53 -------
I have become more than a little bit concerned that this PR is a wild goose
chase.

Applying a similar patch to Erik's, I can persuade some bits of code to do
something.  Furthermore, they are even the same things that ifort9.0 does;
right down to segfaulting in the same places... mostly!  However, getting
anything useful out of such subroutines, even with ifort, is defeating me.

>From 12.4.1.1....

"If the dummy argument is a pointer, the actual argument shall be a pointer and
the types, type parameters and ranks shall agree."

Does this not make an automatic, character-length, pointer dummy incorrect
code?

"At the invocation of the procedure, the dummy argument pointer receives the
pointer association status of the actual argument.  If the actual argument is
currently associated, the the dummy argument becomes associated with the same
target... "  

Thus encouraged, I wrote this:

  SUBROUTINE A(p,l)
    CHARACTER(8), DIMENSION(:), pointer :: p
    if (associated (p)) then
      print *, p
    else
      print *, "not associated"
    end if
  END SUBROUTINE A

  character(8), dimension (:), pointer :: ptr
  character(8), dimension (2), target :: tar
  tar = "def"
  ptr => tar
  call a (ptr)
  if (associated (ptr)) print *, "in MAIN, ptr = ", ptr
  end

ifort decides that p is not associated, whilst gfortran finds p to be
associated but fails to recognise that p is a character and produces a "bad
real" message at the print statement.

It seems to me that, in gfortran, the dummy needs to be declared in the
procedure and its data pointer set to that of the actual argument.  Whether an
automatic character length should work or not seems to be moot to me.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15809


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