public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/23373] New: Functions returning pointers with pointer argument
@ 2005-08-13  9:16 tkoenig at gcc dot gnu dot org
  2005-08-13  9:31 ` [Bug fortran/23373] " pault at gcc dot gnu dot org
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2005-08-13  9:16 UTC (permalink / raw)
  To: gcc-bugs

There is a bad case of aliasing here:

$ cat pointer_function.f90
program Realloc
  IMPLICIT NONE
  REAL, DIMENSION(:), POINTER :: x
  INTEGER :: i
  x => NULL()
  x => myallocate(x)
contains
  FUNCTION myallocate(p)
    REAL, DIMENSION(:), POINTER :: p, myallocate
    INTEGER :: nold,ierr
    if (associated(p)) then
       print *,"p is associated"
    else
       print *,"p is not associated"
    end if
    allocate(myallocate(20))
    if (associated(p)) then
       print *,"p is associated"
    else
       print *,"p is not associated"
    end if
  END FUNCTION myallocate
end program Realloc
$ gfortran -fdump-tree-original pointer_function.f90
$ ./a.out
 p is not associated
 p is associated
$ tail -10 pointer_function.f90.t02.original
{
  struct array1_real4 x;
  static void myallocate (struct array1_real4 &, struct array1_real4 &);

  x.data = 0B;
  x.data = 0B;
  myallocate (&x, &x);
}

The two arguments to myallocate are bogus - they alias each other,
and they shouldn't.  A tempoaray array descriptor is needed here.

-- 
           Summary: Functions returning pointers with pointer argument
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tkoenig at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


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


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

end of thread, other threads:[~2005-09-18 20:27 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-13  9:16 [Bug fortran/23373] New: Functions returning pointers with pointer argument tkoenig at gcc dot gnu dot org
2005-08-13  9:31 ` [Bug fortran/23373] " pault at gcc dot gnu dot org
2005-08-13 11:47 ` tkoenig at gcc dot gnu dot org
2005-08-13 11:47 ` tkoenig at gcc dot gnu dot org
2005-08-13 18:43 ` tobi at gcc dot gnu dot org
2005-08-13 18:51 ` tobi at gcc dot gnu dot org
2005-08-14 15:53 ` tobi at gcc dot gnu dot org
2005-09-07 15:59 ` rsandifo at gcc dot gnu dot org
2005-09-07 16:58 ` rsandifo at gcc dot gnu dot org
2005-09-07 17:04 ` tobi at gcc dot gnu dot org
2005-09-07 17:07 ` richard at codesourcery dot com
2005-09-08  9:20 ` cvs-commit at gcc dot gnu dot org
2005-09-08  9:21 ` rsandifo at gcc dot gnu dot org
2005-09-18 19:50 ` [Bug fortran/23373] [4.0 only] " tkoenig at gcc dot gnu dot org
2005-09-18 20:02 ` pinskia at gcc dot gnu dot org
2005-09-18 20:10 ` rsandifo at gcc dot gnu dot org
2005-09-18 20:27 ` pinskia at gcc dot gnu dot 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).