public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/41139]  New: [4.5 Regression] a procedure pointer call as actual argument
@ 2009-08-21 13:22 janus at gcc dot gnu dot org
  2009-08-21 13:24 ` [Bug fortran/41139] " janus at gcc dot gnu dot org
                   ` (20 more replies)
  0 siblings, 21 replies; 22+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-08-21 13:22 UTC (permalink / raw)
  To: gcc-bugs

PROGRAM test

 PROCEDURE(add), POINTER :: f

 ! Passing the function works
 print *,greater(4.,add(1.,2.))

 ! Passing the procedure pointer fails
 f => add
 print *,greater(4.,f(1.,2.))

CONTAINS

 REAL FUNCTION add(x,y)
   REAL, INTENT(in) :: x,y
   print *,"add:",x,y
   add = x+y
 END FUNCTION add

 LOGICAL FUNCTION greater(x,y)
   REAL, INTENT(in) :: x, y
   greater = (x > y)
 END FUNCTION greater

END PROGRAM test


This code produces the following output:

 add:   1.0000000       2.0000000    
 T
 add:   1.0000000       2.0000000    
Segmentation fault


Looking at the ouput of -fdump-tree-original, one can see a difference between
the two calls to 'greater':

      D.1563 = add (&C.1561, &C.1562);
      D.1564 = greater (&C.1560, &D.1563);

      D.1570 = greater (&C.1567, f (&C.1568, &C.1569));

I.e. in the first case a temporary variable is inserted for the result of
'add', while in the second case this is not the case (which is the reason for
the segfault).

gfortran 4.4 behaves correctly.

Reported by Barron Bichon.


-- 
           Summary: [4.5 Regression] a procedure pointer call as actual
                    argument
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: janus at gcc dot gnu dot org


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


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

end of thread, other threads:[~2009-08-30  2:07 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-21 13:22 [Bug fortran/41139] New: [4.5 Regression] a procedure pointer call as actual argument janus at gcc dot gnu dot org
2009-08-21 13:24 ` [Bug fortran/41139] " janus at gcc dot gnu dot org
2009-08-21 13:35 ` dominiq at lps dot ens dot fr
2009-08-21 13:51 ` janus at gcc dot gnu dot org
2009-08-21 13:58 ` dominiq at lps dot ens dot fr
2009-08-21 14:01 ` janus at gcc dot gnu dot org
2009-08-21 14:03 ` janus at gcc dot gnu dot org
2009-08-21 14:50 ` janus at gcc dot gnu dot org
2009-08-21 15:11 ` janus at gcc dot gnu dot org
2009-08-21 17:08 ` dominiq at lps dot ens dot fr
2009-08-21 18:03 ` burnus at gcc dot gnu dot org
2009-08-21 18:04 ` burnus at gcc dot gnu dot org
2009-08-21 20:27 ` janus at gcc dot gnu dot org
2009-08-22  8:57 ` dominiq at lps dot ens dot fr
2009-08-22  9:19 ` janus at gcc dot gnu dot org
2009-08-22  9:27 ` dominiq at lps dot ens dot fr
2009-08-22  9:43 ` janus at gcc dot gnu dot org
2009-08-23 21:15 ` janus at gcc dot gnu dot org
2009-08-24  1:06 ` mmitchel at gcc dot gnu dot org
2009-08-25 14:27 ` janus at gcc dot gnu dot org
2009-08-25 14:29 ` janus at gcc dot gnu dot org
2009-08-30  2:07 ` hjl 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).